Announcement Announcement Module
No announcement yet.
Inner class problems in Groovy-Eclipse Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Inner class problems in Groovy-Eclipse

    Earlier this year, I worked on a new project until about May. At that point, I had an STS 2.8.1 installation that worked, and the project had been successfully upgraded to Grails 2.0.0. So far so good.

    The project only has tests in it, as it contains functional tests written using Spock to be run against a RESTful web service.

    Last week, I picked the project up again, and by this time, my STS had been upgraded to 2.9.1. Importing the project into the workspace I saw strange error markers in two of the test specs, with text starting with "Found unexpected MOP methods in the class node".

    I tried GGTS 3.0.0 - same problem.

    By removing all the code, and re-adding it bit by bit, I've narrowed the problem down to an anonymous inner class.

    The offending code looks like this:
    import javax.servlet.http.HttpServletResponse
    import static
    import static*
    import org.apache.http.conn.scheme.Scheme
    import org.apache.http.conn.ssl.*
    import spock.lang.*
    class BaseSpecification extends Specification {
      	protected RESTClient makeRESTCLient(String url) {
      		def rest = new RESTClient(url)
                    SSLSocketFactory sf = new SSLSocketFactory(new TrustStrategy {
                      public boolean isTrusted(X509Certificate[] chain,
                      String authType) throws CertificateException {
                          return true
                    }, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER)
      				new Scheme("https", sf, 8443))
      		return rest
    The fix is to replace the inner class with this:
      		SSLSocketFactory sf = new SSLSocketFactory(new NewTrustStrategy(), SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER)
    and define NewTrustStrategy as a normal class.

    This seems to be a regression in the Groovy-Eclipse joint compiler - there are no such problems with the Groovy compiler used by Grails 2.0.0.

    Has anyone come across this before? Is there a known limitation in the latest Groovy-Eclipse compiler?

    I'm happy to raise an issue if it is a regression.


  • #2
    This hasn't solved all my problems with GGTS. Now I have some kind of classpath issue, as the markers now indicate the BaseSpecification cannot be found.

    I have created a fresh Grails project and copied the source code and a snippet of configuration from BuildConfig.groovy from the original project I had problems with.

    I really wouldn't expect any kind of classpath issues here, unless for some reason, the test classes are not being compiled, or the classpath GGTS uses is in some way corrupted.

    I'm pulling my hair out with this issue, as it's such an innocuous project - there's so little to go wrong, and so much has!!

    If anyone can shed light on the MOP issue, or the classpath issues I'm having, I'd be very grateful!