[
https://issues.apache.org/jira/browse/NETBEANS-531?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16517652#comment-16517652
]
Jeffrey Morlan commented on NETBEANS-531:
-----------------------------------------
I've been seeing this in a large Java 8/Maven project. Whenever I change a
dependency in pom.xml, NetBeans recompiles all the files, and for many of them
it often generates invalid class files that fail at runtime with an error like
java.lang.ClassFormatError: Duplicate method name "lambda$main$0" with
signature "()V" in class file main/Main
If I look at the class file, only the last method contains the actual lambda
code, all the others just do 'throw new RuntimeException("Uncompilable source
code")'.
With each dependency change, the class accumulates another erroneous copy of
each lambda method. Making any change to the .java file will reset it.
This only happens if the project has 500+ files. This is probably related to
NBJavacCompileWorkerProvider's choice of different compilation strategies for
<500 or >=500 files changed.
I've attached a minimal project which can reproduce this issue fairly reliably.
Try running Main - first time, it should work. Then edit the dependency in
pom.xml. Most of the time, you'll see the size of Main.class increase, and
it'll fail to run.
[^lambda-bug.tar.gz]
> "Duplicate method name&signature in class" when running maven app with CoS
> enabled
> ----------------------------------------------------------------------------------
>
> Key: NETBEANS-531
> URL: https://issues.apache.org/jira/browse/NETBEANS-531
> Project: NetBeans
> Issue Type: Bug
> Components: java - Classfile, java - Compiler, projects - Maven
> Affects Versions: 9.0
> Environment: Apache NetBeans IDE Dev (Build
> incubator-netbeans-release-205-on-20180202) on OpenJDK 64-Bit Server VM
> 9.0.4.1+11, Mac OS X version 10.9.5 running on x86_64; UTF-8; en_US (nb)
> Reporter: Eirik Bakke
> Priority: Major
> Attachments: duplicatenamesig.txt, lambda-bug.tar.gz
>
>
> On several occasions, when running a Maven-based NetBeans Platform app from
> the IDE, the app fails with the exception "java.lang.ClassFormatError:
> Duplicate method name&signature in class file
> com/somepackage/project/actions/SomeClass$1". I suspect this might be related
> to the Compile-on-Save infrastructure. See attached log. A clean build of the
> entire project is then required in order to make the application runnable
> again.
> Previous versions of NetBeans required a clean build after changing
> annotations (see Bugzilla bug
> [221781|https://netbeans.org/bugzilla/show_bug.cgi?id=221781]). However, this
> new error appears even when no annotations have been changed. The specific
> error message shown here is also new to me--it did not appear in previous
> NetBeans versions.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists