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.
|Summary:||NullPointerException at com.sun.tools.javac.jvm.Code.emitop0|
|Product:||java||Reporter:||_ proxity <proxity>|
|Component:||Compiler||Assignee:||Svata Dedic <sdedic>|
|Severity:||normal||CC:||280Z28, adam_myatt, alexvsimon, anebuzelsky, ceklock, eaili, err, hmichel, jbecicka, jeff_rubinoff, jglick, jskrivanek, kamalnetbean, Link_The_Programmer, marfous, mjanicek, mkleint, mmirilovic, narsereg, ralphbenjamin, sdedic, sj-nb, skygo, tzezula|
|Issue Type:||DEFECT||Exception Reporter:||163470|
Proposed changes to javac impl
Description _ proxity 2009-12-08 07:49:29 UTC
Build: NetBeans IDE 6.7 (Build 200906241340) VM: Java HotSpot(TM) Client VM, 1.5.0_22-b03, Java(TM) 2 Runtime Environment, Standard Edition, 1.5.0_22-b03 OS: Linux, 2.6.18-164.6.1.el5, i386 User Comments: proxity: I've removing a jar from a library. After that the IDE was rescanning the projects. Stacktrace: java.lang.NullPointerException at com.sun.tools.javac.jvm.Code.emitop0(Code.java:525) at com.sun.tools.javac.jvm.Items$SelfItem.load(Items.java:360) at com.sun.tools.javac.jvm.Gen.visitIdent(Gen.java:2103) at com.sun.tools.javac.tree.JCTree$JCIdent.accept(JCTree.java:1683) at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:835) at com.sun.tools.javac.jvm.Gen.visitApply(Gen.java:1677)
Comment 2 Dusan Balek 2011-09-29 15:06:25 UTC
*** Bug 188881 has been marked as a duplicate of this bug. ***
Comment 4 Petr Cyhelsky 2012-01-27 11:01:10 UTC
Created attachment 115308 [details] stacktrace on opening of apisupport project
Comment 5 Exceptions Reporter 2012-01-27 11:01:47 UTC
This bug already has 20 duplicates see http://statistics.netbeans.org/exceptions/detail.do?id=163470
Comment 6 Jiri Skrivanek 2012-02-27 09:44:44 UTC
Created attachment 116129 [details] stacktrace Scanning NetBeans sources...
Comment 7 Sergey Petrov 2012-03-01 08:01:07 UTC
Created attachment 116225 [details] stacktrace first start for ide with parsing for imperted projects (settings was imported from 7.1)
Comment 11 Dusan Balek 2012-04-04 13:26:20 UTC
Hard to fix without a reproducible test case. Are you able to reproduce the issue? If so, could you please create a simple test case and attach it to the issue? Thanks.
Comment 12 Jiri Skrivanek 2012-06-14 10:55:49 UTC
Created attachment 120831 [details] stacktrace Opened diff pane while scanning is in progress.
Comment 15 narsereg 2013-03-17 05:48:44 UTC
Created attachment 132707 [details] stacktrace I had this error during background scanning of projects (in this case it was the repository of NetBeans).
Comment 17 skygo 2013-07-08 19:05:38 UTC
Created attachment 136836 [details] stacktrace opening maven projects after installing dev 201307072319
Comment 18 Egor Ushakov 2013-09-02 12:43:32 UTC
Created attachment 139577 [details] stacktrace during unit test
Comment 19 Egor Ushakov 2013-10-03 14:03:57 UTC
Created attachment 140762 [details] stacktrace external build
Comment 20 Alexander Simon 2014-03-21 12:00:33 UTC
Created attachment 146221 [details] stacktrace open file
Comment 21 Alexander Simon 2014-03-21 12:21:49 UTC
46 reports => P2
Comment 22 Exceptions Reporter 2014-07-28 13:07:44 UTC
This bug already has 50 duplicates see http://statistics.netbeans.org/exceptions/detail.do?id=163470
Comment 23 Svata Dedic 2014-08-04 15:12:43 UTC
I've reproduced a NPE in emitop1 and I believe the reason is the same. Steps for reproduction from a clean userdir * Use NB 8.0 or 8.0.1 * checkout NB-7.3 sources * open a NB-7.3 projects java.editor and java.source with dependencies. * wait for the indexing to complete The offending construction is in o.n.api.java.source.TypeMirrorHandle, method resolve(). One switch case branch uses a variable, which is declared in another case branch. If the projects are opened so that nb-javac sources are not available, the IDE will complain that symbols like com.sun.tools.javac.code.Type are not available. The JavaCompiler.desugar() uses Repair translator to 'repair' damaged source: in this particular case, the variable declaration will be replaced by throw exception statement. The variable declarator will therefore cease to exist; the VariableDecl will not be visited to create a proper local and allocate index in the code generator. The symbol, however already contains an index from the definitive assignment analysis. The attached patch changes the code so that the variable decl is removed only if it is NOT used from the following switch branches. As leaving the variable declaration is complex (one must create code to properly initialize the variable, according to its type), if the variable is used from other switch branches, the entire switch is thrown away.
Comment 24 Svata Dedic 2014-08-04 15:14:19 UTC
Created attachment 148529 [details] Proposed changes to javac impl
Comment 25 Svata Dedic 2014-08-04 15:17:10 UTC
*** Bug 226005 has been marked as a duplicate of this bug. ***
Comment 26 Tomas Zezula 2014-08-04 18:48:38 UTC
The patch seems good to me. It removes the whole switch tree when an erroneous variable is used in successive case trees. Thanks Svato!
Comment 27 Svata Dedic 2014-08-05 13:43:09 UTC
Fixed as nb-javac#bddee634c3fc and jet-main#10ac784c2438
Comment 28 Antonin Nebuzelsky 2014-08-06 12:33:36 UTC
Svato, please backport to release801.
Comment 29 Svata Dedic 2014-08-06 21:52:42 UTC
Backported as releases#f30edf532987
Comment 30 Quality Engineering 2014-08-07 02:22:29 UTC
Integrated into 'main-silver', will be available in build *201408070001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/10ac784c2438 User: Svata Dedic <firstname.lastname@example.org> Log: #178299: repair removes entire switch if variable decl is used form multiple cases; see commit nb-javac#bddee634c3fc
Comment 31 Quality Engineering 2014-08-07 14:47:34 UTC
Integrated into 'releases/release801', will be available in build *201408071314* or newer. Wait for official and publicly available build. Changeset: http://hg.netbeans.org/releases/rev/f30edf532987 User: Svata Dedic <email@example.com> Log: #178299: repair removes entire switch if variable decl is used form multiple cases; see commit nb-javac#bddee634c3fc