Bug 178299 - NullPointerException at com.sun.tools.javac.jvm.Code.emitop0
NullPointerException at com.sun.tools.javac.jvm.Code.emitop0
Product: java
Classification: Unclassified
Component: Compiler
All All
: P2 (vote)
: 8.0.1
Assigned To: Svata Dedic
: 188881 226005 (view as bug list)
Depends on:
  Show dependency treegraph
Reported: 2009-12-08 07:49 UTC by _ proxity
Modified: 2014-08-07 14:47 UTC (History)
24 users (show)

See Also:
Issue Type: DEFECT

stacktrace (4.41 KB, text/plain)
2009-12-08 07:49 UTC, _ proxity
stacktrace (4.78 KB, text/plain)
2011-12-02 10:15 UTC, Martin Fousek
stacktrace (4.57 KB, text/plain)
2012-01-27 11:01 UTC, Petr Cyhelsky
stacktrace (4.69 KB, text/plain)
2012-02-27 09:44 UTC, Jiri Skrivanek
stacktrace (4.69 KB, text/plain)
2012-03-01 08:01 UTC, Sergey Petrov
stacktrace (4.91 KB, text/plain)
2012-03-05 07:46 UTC, Petr Cyhelsky
stacktrace (4.69 KB, text/plain)
2012-03-08 12:14 UTC, Jan Becicka
stacktrace (4.92 KB, text/plain)
2012-03-14 01:02 UTC, adam_myatt
stacktrace (4.85 KB, text/plain)
2012-06-14 10:55 UTC, Jiri Skrivanek
stacktrace (4.85 KB, text/plain)
2012-12-07 15:52 UTC, Petr Cyhelsky
stacktrace (5.24 KB, text/plain)
2013-01-22 15:28 UTC, Marian Mirilovic
stacktrace (4.85 KB, text/plain)
2013-03-17 05:48 UTC, narsereg
stacktrace (4.85 KB, text/plain)
2013-03-21 13:27 UTC, Michel Graciano
stacktrace (5.27 KB, text/plain)
2013-07-08 19:05 UTC, skygo
stacktrace (4.85 KB, text/plain)
2013-09-02 12:43 UTC, Egor Ushakov
stacktrace (4.78 KB, text/plain)
2013-10-03 14:03 UTC, Egor Ushakov
stacktrace (4.78 KB, text/plain)
2014-03-21 12:00 UTC, Alexander Simon
Proposed changes to javac impl (3.91 KB, patch)
2014-08-04 15:14 UTC, Svata Dedic
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.

   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 1 _ proxity 2009-12-08 07:49:33 UTC
Created attachment 92279 [details]
Comment 2 Dusan Balek 2011-09-29 15:06:25 UTC
*** Bug 188881 has been marked as a duplicate of this bug. ***
Comment 3 Martin Fousek 2011-12-02 10:15:54 UTC
Created attachment 113742 [details]
Comment 4 Petr Cyhelsky 2012-01-27 11:01:10 UTC
Created attachment 115308 [details]

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]

Scanning NetBeans sources...
Comment 7 Sergey Petrov 2012-03-01 08:01:07 UTC
Created attachment 116225 [details]

first start for ide with parsing for imperted projects (settings was imported from 7.1)
Comment 8 Petr Cyhelsky 2012-03-05 07:46:09 UTC
Created attachment 116338 [details]
Comment 9 Jan Becicka 2012-03-08 12:14:14 UTC
Created attachment 116463 [details]
Comment 10 adam_myatt 2012-03-14 01:02:15 UTC
Created attachment 116695 [details]
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]

Opened diff pane while scanning is in progress.
Comment 13 Petr Cyhelsky 2012-12-07 15:52:53 UTC
Created attachment 129055 [details]
Comment 14 Marian Mirilovic 2013-01-22 15:28:41 UTC
Created attachment 130493 [details]
Comment 15 narsereg 2013-03-17 05:48:44 UTC
Created attachment 132707 [details]

I had this error during background scanning of projects (in this case it was the repository of NetBeans).
Comment 16 Michel Graciano 2013-03-21 13:27:41 UTC
Created attachment 132905 [details]
Comment 17 skygo 2013-07-08 19:05:38 UTC
Created attachment 136836 [details]

opening maven projects after installing dev 201307072319
Comment 18 Egor Ushakov 2013-09-02 12:43:32 UTC
Created attachment 139577 [details]

during unit test
Comment 19 Egor Ushakov 2013-10-03 14:03:57 UTC
Created attachment 140762 [details]

external build
Comment 20 Alexander Simon 2014-03-21 12:00:33 UTC
Created attachment 146221 [details]

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 <sdedic@netbeans.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 <sdedic@netbeans.org>
Log: #178299: repair removes entire switch if variable decl is used form multiple cases; see commit nb-javac#bddee634c3fc

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo