Java 8 not supported #524

Closed
lombokissues opened this Issue Jul 14, 2015 · 37 comments

Projects

None yet

2 participants

@lombokissues
Collaborator

Migrated from Google Code (issue 451)

@lombokissues
Collaborator

👤 lahoda   🕗 Feb 15, 2013 at 12:04 UTC

Seems that lombok does not support Java 8 compiler. I have this simple source code:

package java8test;

import lombok.Getter;

public class GetterTest {

@ Getter
private int i;

}

I am trying Lombok 0.11.6 from https://projectlombok.org/ and javac:
$ javac -fullversion
javac full version "1.8.0-ea-b76"

Trying to compile the source code leads to an exception/warning:
$ javac -classpath lombok.jar GetterTest.java
GetterTest.java:5: warning: Can't initialize javac processor due to (most likely) a class loader problem: java.lang.NoClassDefFoundError: com/sun/tools/javac/code/TypeTags
public class GetterTest {
^
at lombok.javac.handlers.HandleGetter.<clinit>(HandleGetter.java:291)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:261)
at lombok.core.SpiLoadUtil$1$1.next(SpiLoadUtil.java:111)
at lombok.javac.HandlerLibrary.loadAnnotationHandlers(HandlerLibrary.java:167)
at lombok.javac.HandlerLibrary.load(HandlerLibrary.java:152)
at lombok.javac.JavacTransformer.<init>(JavacTransformer.java:43)
at lombok.javac.apt.Processor.init(Processor.java:90)
at lombok.core.AnnotationProcessor$JavacDescriptor.want(AnnotationProcessor.java:89)
at lombok.core.AnnotationProcessor.init(AnnotationProcessor.java:143)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$ProcessorState.<init>(JavacProcessingEnvironment.java:501)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$DiscoveredProcessors$ProcessorStateIterator.next(JavacProcessingEnvironment.java:598)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:691)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:93)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1018)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1152)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1176)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:862)
at com.sun.tools.javac.main.Main.compile(Main.java:506)
at com.sun.tools.javac.main.Main.compile(Main.java:365)
at com.sun.tools.javac.main.Main.compile(Main.java:354)
at com.sun.tools.javac.main.Main.compile(Main.java:345)
at com.sun.tools.javac.Main.compile(Main.java:76)
at com.sun.tools.javac.Main.main(Main.java:61)
Caused by: java.lang.ClassNotFoundException: com.sun.tools.javac.code.TypeTags
at java.net.URLClassLoader$1.run(URLClassLoader.java:359)
at java.net.URLClassLoader$1.run(URLClassLoader.java:348)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:347)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 24 more
1 warning

Note that daily/trunk builds of NetBeans are currently using javac from JDK8, and so lombok does not work on them:
http://netbeans.org/bugzilla/show_bug.cgi?id=226165

Note this does not apply to NetBeans 7.3, which is using JDK7 javac.

@lombokissues
Collaborator

👤 akobberup   🕗 Feb 15, 2013 at 12:19 UTC

As a user of netbeans dev builds and a user of lombok also, i would be very glad to see support for jdk8 in lombok anytime soon!

@lombokissues
Collaborator

👤 r.spilker   🕗 Feb 15, 2013 at 13:16 UTC

@lombokissues
Collaborator

👤 r.spilker   🕗 Feb 15, 2013 at 13:17 UTC

@lombokissues
Collaborator

👤 grootjans   🕗 Mar 08, 2013 at 15:57 UTC

Started a branch on github to add JDK8 support.

@lombokissues
Collaborator

👤 grootjans   🕗 Mar 08, 2013 at 15:58 UTC

https://github.com/rzwitserloot/lombok/tree/jdk8support

@lombokissues
Collaborator

👤 danno.ferrin   🕗 Mar 15, 2013 at 18:01 UTC

Here's a patch NB had to do for the typetags:

http://netbeans.org/projects/java/lists/commits/archive/2013-01/message/141

@lombokissues
Collaborator

👤 miena.moo   🕗 Apr 22, 2013 at 07:17 UTC

Any news on this fix yet? :)

@lombokissues
Collaborator

👤 grootjans   🕗 Apr 22, 2013 at 21:44 UTC

working hard on this, though limited by the free time we invest.

Though JDK8 support is simple enough if we would completely fork lombok for jdk8, or drop support for all previous JDKs, this is just not how we would want this to work. This would also imply using a different lombok jar in netbeans runtime and in the build.

Why is building it in one jar hard? We rely/need the internal AST of javac. In JDK8 they made some changes that are great for the AST, among others introducing actual enums for their constants, but less great for us. We have to make sure that we support, on runtime, both compiler versions.

We're halfway there at this moment, with a few pesky problems to go, and then the challenge to adapt our build to test against JDK8. Untill now we used openJDK builds to test against, but there isn't a build of that yet for us to readily use.

so, stay tuned. This definitely has our attention.

@lombokissues
Collaborator

👤 miena.moo   🕗 Apr 23, 2013 at 05:16 UTC

Thanks a lot for the feedback! I quite understand how difficult maintaining backwards compatibility can be! :)

@lombokissues
Collaborator

👤 bleporini   🕗 Apr 27, 2013 at 06:26 UTC

Hello, is there a repo where a SNAPSHOT release would be available?

Regards

@lombokissues
Collaborator

👤 grootjans   🕗 Apr 27, 2013 at 07:49 UTC

there is a branch on github, where lombok is developed, but no snapshot channel with our maven repo provider.

At this point in time, though, this branch is in the wonderful state that it supports neither Java 7 or Java 8.

@lombokissues
Collaborator

👤 askoning   🕗 May 14, 2013 at 09:41 UTC

Issue #551 has been merged into this issue.

@lombokissues
Collaborator

👤 Marek.Stefaniak   🕗 May 16, 2013 at 03:25 UTC

github branch is not compiling using ant dist.
Compilation error:

lombok-jdk8support/src/utils/lombok/javac/JCNoTypeFactory.java:10: error: missing return statement
[ivy:compile] }
[ivy:compile] ^
[ivy:compile] 1 error

When you have a look at source code:
package lombok.javac;

import com.sun.tools.javac.code.Symbol.TypeSymbol;
import com.sun.tools.javac.code.Type;

public class JCNoTypeFactory {
public static final Type getJCNotType(Object typeTag, TypeSymbol tsym) {

}

}

@lombokissues
Collaborator

👤 michel.graciano   🕗 Jun 28, 2013 at 18:46 UTC

There is any chance to you make available a SNAPSHOT version which works for JDK 8? IMHO you can make available a version which works only at JDK 8 for now, at least for us which wants to make some tests. Thanks in advance.

@lombokissues
Collaborator

👤 r.spilker   🕗 Jul 29, 2013 at 15:40 UTC

We're working on it. We will expect to have something testable within a few weeks. That might sound like a lot of time, but there is a lot to be fixed and we only have so much time :-(

@lombokissues
Collaborator

👤 reinierz   🕗 Sep 09, 2013 at 22:13 UTC

For the fans: We've got an initial release that retains its compatibility (including the new 'copy javadoc from field to generated getters/setters' stuff we've had some issues with) for JDK6/JDK7, and which also works on JDK8, though there are a select few corner cases that don't work yet, including some val corner cases, and the aforementioned javadoc copying thing which simply won't happen when delomboking with a JDK8's javac in your tools.jar of the VM you're running delombok on.

Edge release is available here: https://projectlombok.org/download-edge.html

Please let us know if this works for you, or if it doesn't!

NB: It's time to go to bed; no time yet to test if this actually works on netbeans. Many kudos for the first one to chime in if this'll do it for recent netbeans releases, though!

@lombokissues
Collaborator

👤 michel.graciano   🕗 Sep 10, 2013 at 02:34 UTC

Hi folks,
I have tested with a newly built NetBeans without success. Maybe I am doing something wrong with lombok, but maybe not :)

First of all, I created a project with NetBeans 7.3.1 using lombok-edge with success and just tried to open it at NetBeans trunk build, but with the following error in the IDE log file:

INFO [com.sun.tools.javac.processing.JavacProcessingEnvironment]: Annotation processing error:
java.lang.ClassNotFoundException: com.sun.tools.javac.code.TypeTags
at java.lang.ClassLoader.findClass(ClassLoader.java:522)
at org.netbeans.modules.java.source.parsing.CachingArchiveClassLoader.findClass(CachingArchiveClassLoader.java:106)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:188)
at lombok.javac.JavacTreeMaker$SchroedingerType.getFieldCached(JavacTreeMaker.java:156)
at lombok.javac.JavacTreeMaker$TypeTag.typeTag(JavacTreeMaker.java:244)
at lombok.javac.Javac.(Javac.java:122)
Caused: java.lang.ExceptionInInitializerError
at lombok.javac.handlers.HandleGetter.(HandleGetter.java:296)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:266)
at lombok.core.SpiLoadUtil$1$1.next(SpiLoadUtil.java:111)
at lombok.javac.HandlerLibrary.loadAnnotationHandlers(HandlerLibrary.java:167)
at lombok.javac.HandlerLibrary.load(HandlerLibrary.java:152)
at lombok.javac.JavacTransformer.(JavacTransformer.java:43)
at lombok.javac.apt.Processor.init(Processor.java:86)
at lombok.core.AnnotationProcessor$JavacDescriptor.want(AnnotationProcessor.java:89)
at lombok.core.AnnotationProcessor.init(AnnotationProcessor.java:143)
[catch] at com.sun.tools.javac.processing.JavacProcessingEnvironment$ProcessorState.(JavacProcessingEnvironment.java:510)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$DiscoveredProcessors$ProcessorStateIterator.next(JavacProcessingEnvironment.java:610)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:703)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$2000(JavacProcessingEnvironment.java:91)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1048)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1111)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1206)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1093)
at com.sun.tools.javac.api.JavacTaskImpl.enter(JavacTaskImpl.java:375)
at com.sun.tools.javac.api.JavacTaskImpl.enter(JavacTaskImpl.java:310)
at org.netbeans.modules.java.source.parsing.JavacParser.moveToPhase(JavacParser.java:653)
at org.netbeans.modules.java.source.parsing.JavacParser.getResult(JavacParser.java:521)
at org.netbeans.modules.java.source.parsing.JavacParser.getResult(JavacParser.java:174)
at org.netbeans.modules.parsing.impl.TaskProcessor.callGetResult(TaskProcessor.java:615)
at org.netbeans.modules.parsing.impl.SourceCache.getResult(SourceCache.java:256)
at org.netbeans.modules.parsing.impl.TaskProcessor$CompilationJob.run(TaskProcessor.java:727)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1432)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2042)

and the following error at IDE editor:

Can't initialize javac processor due to (most likely) a class loader problem: java.lang.NoClassDefFoundError: Could not initialize class lombok.javac.handlers.HandleGetter
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:266)
at lombok.core.SpiLoadUtil$1$1.next(SpiLoadUtil.java:111)
at lombok.javac.HandlerLibrary.loadAnnotationHandlers(HandlerLibrary.java:167)
at lombok.javac.HandlerLibrary.load(HandlerLibrary.java:152)
at lombok.javac.JavacTransformer.(JavacTransformer.java:43)
at lombok.javac.apt.Processor.init(Processor.java:86)
at lombok.core.AnnotationProcessor$JavacDescriptor.want(AnnotationProcessor.java:89)
at lombok.core.AnnotationProcessor.init(AnnotationProcessor.java:143)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$ProcessorState.(JavacProcessingEnvironment.java:510)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$DiscoveredProcessors$ProcessorStateIterator.next(JavacProcessingEnvironment.java:610)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:703)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$2000(JavacProcessingEnvironment.java:91)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1048)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1111)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1206)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1093)
at com.sun.tools.javac.api.JavacTaskImpl.enter(JavacTaskImpl.java:375)
at com.sun.tools.javac.api.JavacTaskImpl.enter(JavacTaskImpl.java:310)
at org.netbeans.modules.java.source.parsing.JavacParser.moveToPhase(JavacParser.java:653)
at org.netbeans.modules.java.source.parsing.JavacParser.getResult(JavacParser.java:521)
at org.netbeans.modules.java.source.parsing.JavacParser.getResult(JavacParser.java:174)
at org.netbeans.modules.parsing.impl.TaskProcessor.callGetResult(TaskProcessor.java:615)
at org.netbeans.modules.parsing.impl.SourceCache.getResult(SourceCache.java:256)
at org.netbeans.modules.parsing.impl.TaskProcessor$CompilationJob.run(TaskProcessor.java:727)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1432)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2042)

I have tried even with the project configured to use JDK 7 and 8, with the same result. Can I do anything else to proceed the tests?

Thanks in advance.

@lombokissues
Collaborator

👤 michel.graciano   🕗 Sep 10, 2013 at 02:36 UTC

One additional comment is that I have enabled Annotation Processors in Editor at project properties.

@lombokissues
Collaborator

👤 michel.graciano   🕗 Sep 10, 2013 at 02:42 UTC

I am attaching a sample project which works at NetBeans 7.3.1 but does not works for NetBeans trunk. I will test it against NetBeans 7.4 Beta tomorrow, but in the meantime I hope you can take a look at this.

Regards

@lombokissues
Collaborator

👤 michel.graciano   🕗 Sep 10, 2013 at 02:42 UTC

🔗 LombokTestApp.zip

@lombokissues
Collaborator

👤 reinierz   🕗 Sep 23, 2013 at 22:09 UTC

Okay, we found it. Turns out calling JavaCompiler.version() doesn't return "1.8" as you might expect, but "(version info not available)". Dunce hat to team netbeans for that marvellous implementation of the 'version()' method. We found an alternate slightly hacky way (inspect the valid options for the -source parameter and parse the last one in the enum), which seems to be holding up. We only use it if the JavaCompiler.version() call produced a silly result.

We'll try and push an updated edge release out the door later today, we have some debug work to undo :)

@lombokissues
Collaborator

👤 michel.graciano   🕗 Sep 23, 2013 at 22:21 UTC

Shouldn't we try to patch NetBeans too? If you point me exactly in your code where do you need this info, I can try to debug and submit a patch directly to NetBeans team.
Thanks for your hard work and let me know as soon as you have a edge build.

@lombokissues
Collaborator

👤 matthew@jaggard.org.uk   🕗 Sep 23, 2013 at 22:27 UTC

You know it's managed by oracle right?

@lombokissues
Collaborator

👤 jirka.hana   🕗 Sep 23, 2013 at 22:32 UTC

The last time I submitted a patch to NB, it was accepted and integrated
pretty fast. Similarly bug reports were taken care of reasonably fast

@lombokissues
Collaborator

👤 michel.graciano   🕗 Sep 23, 2013 at 22:37 UTC

Yes, I know. I have been working with NetBeans team for more than a decade with huge success. I already have all the papers signed for OCA and so on, so if it really is a NetBeans issue, I am pretty sure we can handle it in NetBeans side too. I will take a look at this one today yet and maybe submit something asap. If you give me some coordinates at you code base, it gonna be easier to me. I hope I can handle NetBeans easier since I am already used to.

@lombokissues
Collaborator

👤 michel.graciano   🕗 Sep 23, 2013 at 23:28 UTC

I have filed a issue against it https://netbeans.org/bugzilla/show_bug.cgi?id=236297. I am still working on it, so lets see if we have a workable patch soon.

@lombokissues
Collaborator

👤 reinierz   🕗 Sep 23, 2013 at 23:34 UTC

Allright, new edge is built. We tested it ourselves on netbeans 7.4RC1 and a very casual test now indicates that this new edge version should do allright.

Team netbeans users: Give it a new spin? Thanks a bunch!

https://projectlombok.org/download-edge.html

@lombokissues
Collaborator

👤 reinierz   🕗 Sep 23, 2013 at 23:38 UTC

@ michel.graciano: Yup, the resource file that contains the version stuff just isn't there, for some reason. The relevant code line is JavaCompiler's private static String version(String key) method. It loads resource "com.sun.tools.javac.resources.version", and it isn't there in netbeans's internal javac.

@lombokissues
Collaborator

👤 michel.graciano   🕗 Sep 23, 2013 at 23:51 UTC

Hey guys, tested with success in NetBeans 7.4 daily build. Tomorrow I will test it more at work, with a bigger project (here I have just some test and simple projects), but so far so good. If some face some issus, you need just to remove your index cache (http://wiki.netbeans.org/FaqWhatIsUserdir). Thanks again guys.

@lombokissues
Collaborator

👤 piderman   🕗 Sep 24, 2013 at 08:02 UTC

The fix seems to work on this end. I have tested the edge version of lombok in Netbeans 7.4RC1 and the errors go away. Reverting to lombok 0.12.0 brings the errors back, as expected.

@lombokissues
Collaborator

👤 DigitalZuzEL   🕗 Sep 24, 2013 at 08:13 UTC

Thats great! When will you release stable version? Thanks again!

@lombokissues
Collaborator

👤 michel.graciano   🕗 Oct 11, 2013 at 13:41 UTC

Lombok has released a stable version with this fix, but looks like we have a regression here. I am not sure if it is a regression from NetBeans or Lombok side, so I have filed in both projects. The Lombok issue is issue #626.

Regards

@lombokissues
Collaborator

👤 michel.graciano   🕗 Oct 16, 2013 at 16:25 UTC

I have updated issue #626 with NetBeans team comments and it is a Lombok issue. I should add that Lombok 1.12.2 is not even recommended to use with NetBeans 7.3.1.

@lombokissues
Collaborator

👤 lennyprimak   🕗 Oct 21, 2013 at 04:58 UTC

I am hitting this bug (Issue #626) as well. This makes NB 7.4 / lombok combination unusable.
I consider Issue #626 and Issue #524 a critical issue.

@lombokissues
Collaborator

👤 r.spilker   🕗 Oct 22, 2013 at 16:10 UTC

I'm going to close this issue, since most of the comments are about the Netbeans support, which is covered by issue #626. I'll create new issues regarding java 8 language support for both Eclipse and javac.

@lombokissues lombokissues removed the accepted label Jul 14, 2015
@lombokissues
Collaborator

End of migration

@sfat sfat referenced this issue in jcabi/jcabi-aspects Nov 16, 2015
Open

Master build fail #182

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