Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6889255
Votes 0
Synopsis javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
Category java:compiler
Reported Against
Release Fixed 7(b75)
State 10-Fix Delivered, bug
Priority: 3-Medium
Related Bugs 6572945 , 6888888
Submit Date 07-OCT-2009
Description
When core classes are built for debug (-g flag) javah throws an unexpected
java.lang.NullPointerException while working in jdk/make/java/nio:

An exception has occurred in the compiler (1.7.0-tbell_2009_10_05.23.59.01_bootstrap). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport)  after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report.  Thank you.
java.lang.NullPointerException
        at com.sun.tools.javac.code.Symbol$MethodSymbol.params(Symbol.java:1226)
        at com.sun.tools.javac.code.Symbol$MethodSymbol.getParameters(Symbol.java:1252)
        at com.sun.tools.javac.code.Symbol$MethodSymbol.getParameters(Symbol.java:1014)
        at javax.lang.model.util.ElementScanner6.visitExecutable(ElementScanner6.java:191)
        at com.sun.tools.javac.code.Symbol$MethodSymbol.accept(Symbol.java:1260)
        at javax.lang.model.util.ElementScanner6.scan(ElementScanner6.java:139)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment$ComputeAnnotationSet.scan(JavacProcessingEnvironment.java:767)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment$ComputeAnnotationSet.scan(JavacProcessingEnvironment.java:745)
        at javax.lang.model.util.ElementScanner6.scan(ElementScanner6.java:129)
        at javax.lang.model.util.ElementScanner6.visitType(ElementScanner6.java:169)
        at com.sun.tools.javac.code.Symbol$ClassSymbol.accept(Symbol.java:874)
        at javax.lang.model.util.ElementScanner6.scan(ElementScanner6.java:139)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment$ComputeAnnotationSet.scan(JavacProcessingEnvironment.java:767)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment$ComputeAnnotationSet.scan(JavacProcessingEnvironment.java:745)
        at javax.lang.model.util.ElementScanner6.scan(ElementScanner6.java:129)
        at javax.lang.model.util.ElementScanner6.visitType(ElementScanner6.java:169)
        at com.sun.tools.javac.code.Symbol$ClassSymbol.accept(Symbol.java:874)
        at javax.lang.model.util.ElementScanner6.scan(ElementScanner6.java:139)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment$ComputeAnnotationSet.scan(JavacProcessingEnvironment.java:767)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:825)
        at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1070)
        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:805)
        at com.sun.tools.javac.main.Main.compile(Main.java:400)
        at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:139)
        at com.sun.tools.javah.JavahTask.run(JavahTask.java:482)
        at com.sun.tools.javah.JavahTask.run(JavahTask.java:319)
        at com.sun.tools.javah.Main.main(Main.java:46)


Bug-ID 6888888 is the short term workaround, which is to use the bootstrap javah instead.

This bug report is for the eventual fix.
Posted Date : 2009-10-07 19:13:49.0
Work Around
N/A
Evaluation
The problem is actually in javac, not javah per se.

Fundamentally, the problem is in javac ClassReader, which is not correctly reading the saved parameter names. It reads too few names, which causes an NPE in MethodSymbol when using iterators to correlate the list of names with the list of parameters.

There are many things wrong in the ClassReader code:

1) the main reason causing the observed NPE is that the name reading code does not take into account the adjustment to the MethodType in readMethod to ignore the synthetic parameter this$0.  Given this error, it then fails to correctly match up names to parameters.

2) the name reading code assumes a single LocalVariableTable (which is not required)

3) the name reading code assumes that all the parameters are named (which is not required)

4) the name reading code assumes that the parameters are named in order (which is not required)

These are all long-standing issues and not the result of any recent changes.   The issue with javah is just that by using annotation processing, it is tickling these bugs in ClassReader.
Posted Date : 2009-10-08 20:09:57.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang