Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

@Function compilation bug #89

Closed
nicholas22 opened this Issue Jun 22, 2012 · 4 comments

Comments

Projects
None yet
2 participants
Collaborator

nicholas22 commented Jun 22, 2012

I'm getting a compilation error when building with Gradle, in a @function annotated method:
(I believe it uses Javac though)

    /**
     * Parses a String subscription to a concrete object
     */
    @Function
    @SneakyThrows
    private static SourceSubscription parse(String subscription)
    {
      try
      {
        val parts = StringUtils.split(subscription, CONSTANT.HYPHEN);
        if (parts.length != 2)
          throw new IllegalArgumentException();

        return new SourceSubscription(parts[0], parts[1]);
      }
      catch(Exception e)
      {
        throw new IllegalArgumentException("Invalid subscription: " + subscription);
      }
    }

The work-around is to manually code:

    /**
     * Parses a String subscription to a concrete object
     */
    @SneakyThrows
    private static Function1<String, SourceSubscription> parse()
    {
      return new Function1<String, SourceSubscription>() {

        @Override
        public SourceSubscription apply(String subscription)
        {
          try
          {
            val parts = StringUtils.split(subscription, CONSTANT.HYPHEN);
            if (parts.length != 2)
              throw new IllegalArgumentException();

            // return new
            return new SourceSubscription(parts[0], parts[1]); 
          }
          catch(Exception e)
          {
            throw new IllegalArgumentException("Invalid subscription: " + subscription);
          }
        }
      };
    }

The error I get is:

java.lang.NullPointerException
at com.sun.tools.javac.comp.MemberEnter.getMethodEnv(MemberEnter.java:65
8)
at lombok.javac.JavacResolution$EnvFinder.visitMethodDef(JavacResolution
.java:292)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:639)
at lombok.javac.JavacResolution.resolveMethodMember(JavacResolution.java
:325)
at lombok.javac.handlers.HandleVal.visitLocal(HandleVal.java:96)
at lombok.javac.JavacNode.traverse(JavacNode.java:92)
at lombok.javac.JavacAST.traverseChildren(JavacAST.java:122)
at lombok.javac.JavacNode.traverse(JavacNode.java:98)
at lombok.javac.JavacAST.traverseChildren(JavacAST.java:122)
at lombok.javac.JavacNode.traverse(JavacNode.java:98)
at lombok.javac.JavacAST.traverseChildren(JavacAST.java:122)
at lombok.javac.JavacNode.traverse(JavacNode.java:98)
at lombok.javac.JavacAST.traverseChildren(JavacAST.java:122)
at lombok.javac.JavacNode.traverse(JavacNode.java:98)
at lombok.javac.JavacAST.traverseChildren(JavacAST.java:122)
at lombok.javac.JavacNode.traverse(JavacNode.java:77)
at lombok.javac.JavacAST.traverseChildren(JavacAST.java:122)
at lombok.javac.JavacNode.traverse(JavacNode.java:67)
at lombok.javac.JavacAST.traverseChildren(JavacAST.java:122)
at lombok.javac.JavacNode.traverse(JavacNode.java:98)
at lombok.javac.JavacAST.traverseChildren(JavacAST.java:122)
at lombok.javac.JavacNode.traverse(JavacNode.java:98)
at lombok.javac.JavacAST.traverseChildren(JavacAST.java:122)
at lombok.javac.JavacNode.traverse(JavacNode.java:77)
at lombok.javac.JavacAST.traverseChildren(JavacAST.java:122)
at lombok.javac.JavacNode.traverse(JavacNode.java:67)
at lombok.javac.JavacAST.traverseChildren(JavacAST.java:122)
at lombok.javac.JavacNode.traverse(JavacNode.java:62)
at lombok.javac.JavacAST.traverse(JavacAST.java:117)
at lombok.javac.HandlerLibrary.callASTVisitors(HandlerLibrary.java:211)
at lombok.javac.JavacTransformer.transform(JavacTransformer.java:73)
at lombok.javac.apt.Processor.process(Processor.java:217)
at lombok.core.AnnotationProcessor$JavacDescriptor.process(AnnotationPro
cessor.java:117)
at lombok.core.AnnotationProcessor.process(AnnotationProcessor.java:169)

@ghost ghost assigned peichhorn Jun 22, 2012

Owner

peichhorn commented Jun 22, 2012

Thanks for the example. I will look into it.

Owner

peichhorn commented Jun 22, 2012

fixed it.. also added a test for this scenario.. man I really need to work on a concept of prioritizing lombok handlers..

@peichhorn peichhorn closed this Jun 22, 2012

Owner

peichhorn commented Jun 22, 2012

I've deployed a new lombok-pg 0.11.1-SNAPSHOT.

Collaborator

nicholas22 commented Jun 25, 2012

That was quick! Thanks xD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment