This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 142848 - Broken classfiles when using Quick Run
Summary: Broken classfiles when using Quick Run
Status: VERIFIED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 6.x
Hardware: All All
: P1 blocker (vote)
Assignee: Jan Lahoda
URL:
Keywords:
: 142808 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-08-04 20:25 UTC by Jesse Glick
Modified: 2008-10-17 16:16 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Diff against release65_beta (2.97 KB, patch)
2008-08-06 11:51 UTC, Jan Lahoda
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2008-08-04 20:25:43 UTC
1. Open contrib/autoproject.kit and run Debug. Rest of steps in tested IDE.

2. svn checkout http://google-guice.googlecode.com/svn/trunk/ google-guice-read-only

3. Open Guice project.

4. Alt-F6 and accept 'test' target.

5. There will be two failures that I see. Click on hyperlink for ScopesTest. Press Shift-F6 to (re-)run it.

6. I get

Testcase: testSingletons(com.google.inject.ScopesTest):        Caused an ERROR
Repetitive method name/signature in class file com/google/inject/Stage
java.lang.ClassFormatError: Repetitive method name/signature in class file com/google/inject/Stage
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
        at com.google.inject.Guice.createInjector(Guice.java:70)
        at com.google.inject.Guice.createInjector(Guice.java:60)
        at com.google.inject.ScopesTest.testSingletons(ScopesTest.java:57)

etc.

7. Open Stage.java, modify (e.g. insert then delete a space at EOF), and save. Rerun ScopesTest. Now I get

Testcase: testSingletons(com.google.inject.ScopesTest):        Caused an ERROR
Absent Code attribute in method that is not native or abstract in class file com/google/inject/InjectorImpl
java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file
com/google/inject/InjectorImpl
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
        at com.google.inject.InjectorBuilder.build(InjectorBuilder.java:90)
        at com.google.inject.Guice.createInjector(Guice.java:132)
        at com.google.inject.Guice.createInjector(Guice.java:93)
        at com.google.inject.Guice.createInjector(Guice.java:70)
        at com.google.inject.Guice.createInjector(Guice.java:60)
        at com.google.inject.ScopesTest.testSingletons(ScopesTest.java:57)

8. Open InjectorImpl.java, modify, save. Rerun test. Now

java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file
com/google/inject/internal/ReferenceCache

etc. etc.
Comment 2 Quality Engineering 2008-08-06 04:31:45 UTC
Integrated into 'main-golden', available in build *200808060201* on http://bits.netbeans.org/dev/nightly/
Changeset: http://hg.netbeans.org/main/rev/d9f8d2ce40c0
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #142848: another attempt for correct generation of package-info.class
Comment 3 Jan Lahoda 2008-08-06 10:51:56 UTC
The bug was caused by:
http://hg.netbeans.org/main?cmd=changeset;node=2beb1fbd8baa

After this change, each time a package-info.java was encountered, all classes parsed so far were dumped into .class
files (and the current instance of the parser was discarded). If the following conditions were met:
-a dumped .class file contained a static initializer
-the dumped .class file was loaded and then parsed from the source
then the final .class file contained duplicated static initializer, one of them without code attribute (the one that
originated in the first .class file)

The solution is twofold:
-rollback of 2beb1fbd8baa (which fixes this problem, but will break generation of .class file for package-info.java)
-(more) correct fix for generation of .class files for package-info.java: make JavacTaskImpl.enter return a TypeElement
for content package-info.java, so it can be passed to JTI.generate, which will then generate only the single .class file
corresponding to package-info.java

Risks:
-negative impact to files other than package-info.java is very unlikely
-two possible problems for package-info.java:
 -generation of .class files for package-info might break (please note that .class files are never generated for "empty"
package-infos)
 -processing of package-infos might break
 I consider both of these problems to be not very likely.
Comment 4 Jiri Prox 2008-08-06 11:51:08 UTC
Wrong class generation is very serious problem ->  P1
this should be fixed in beta, in order to test the fix properly 
Comment 5 Jan Lahoda 2008-08-06 11:51:43 UTC
Created attachment 66665 [details]
Diff against release65_beta
Comment 6 Jan Lahoda 2008-08-06 11:53:15 UTC
The patch against release65_beta is attached. The changes in the parser are here:
http://hg.netbeans.org/main/nb-javac?cmd=changeset;node=ed452dfda4c8

Dusan, could you please review the fix? Thanks.
Comment 7 Dusan Balek 2008-08-06 12:18:49 UTC
The fix seems to be OK.
Comment 8 Jiri Prox 2008-08-06 17:04:36 UTC
i cannot reproduce it with current trunk -> verified by QA
Comment 9 Jan Lahoda 2008-08-06 19:28:44 UTC
*** Issue 142808 has been marked as a duplicate of this issue. ***
Comment 10 Jesse Glick 2008-08-07 00:21:42 UTC
Confirmed, fix works on my test case. Thanks! (BTW rerunning a single failed test method works in this project now too.)
Comment 11 Jan Lahoda 2008-08-07 14:51:59 UTC
Merged into release65_beta branch:
http://hg.netbeans.org/release65_beta/rev/50b2377449b2