United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 6348499 javac crashes at com.sun.tools.javac.jvm.ClassReader$BadClassFile
6348499 : javac crashes at com.sun.tools.javac.jvm.ClassReader$BadClassFile

Details
Type:
Bug
Submit Date:
2005-11-10
Status:
Open
Updated Date:
2010-10-20
Project Name:
JDK
Resolved Date:
Component:
tools
OS:
generic
Sub-Component:
javac
CPU:
sparc,generic
Priority:
P4
Resolution:
Unresolved
Affected Versions:
6
Targeted Versions:

Related Reports
Relates:
Relates:

Sub Tasks

Description
The javac crashes at "com.sun.tools.javac.jvm.ClassReader$BadClassFile" when trying to handle with the class file that is created by the '(new Filer()).createClassFile()' method.

Pasting the error messages below. Also attached the source code with the bug report.

<Error-MSG>
bash-2.05$ /jdk/sol/b292b/j2sdk1.6.0/bin/javac -J-version
java version "1.6.0-auto"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-auto-304a)
Java HotSpot(TM) Client VM (build 1.6.0-ea-b58, mixed mode)

bash-2.05$ javac -cp /jdk/sol/b304a/j2sdk1.6.0/lib/tools.jar:. -processor simpleAP -processorpath simpleAP.jar -proc:only B.java
@visitType()
B
An exception has occurred in the compiler (1.6.0-auto). 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.
com.sun.tools.javac.jvm.ClassReader$BadClassFile: bad class file: newfile.class
illegal start of class file
Please remove or make sure it appears in the correct subdirectory of the classpath.
	at com.sun.tools.javac.jvm.ClassReader.badClassFile(ClassReader.java:248)
	at com.sun.tools.javac.jvm.ClassReader.readClassFile(ClassReader.java:1367)
	at com.sun.tools.javac.jvm.ClassReader.fillIn(ClassReader.java:1528)
	at com.sun.tools.javac.jvm.ClassReader.complete(ClassReader.java:1471)
	at com.sun.tools.javac.code.Symbol.complete(Symbol.java:370)
	at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:740)
	at com.sun.tools.javac.code.Symbol$ClassSymbol.getAnnotationMirrors(Symbol.java:682)
	at com.sun.tools.javac.model.JavacElements.getAllAnnotationMirrors(JavacElements.java:408)
	at com.sun.tools.javac.model.JavacElements.getAllAnnotationMirrors(JavacElements.java:46)
	at com.sun.tools.javac.processing.JavacProcessingEnvironment$ComputeAnnotationSet.scan(JavacProcessingEnvironment.java:477)
	at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:627)
	at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:843)
	at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:629)
	at com.sun.tools.javac.main.Main.compile(Main.java:756)
	at com.sun.tools.javac.main.Main.compile(Main.java:681)
	at com.sun.tools.javac.main.Main.compile(Main.java:670)
	at com.sun.tools.javac.Main.compile(Main.java:70)
	at com.sun.tools.javac.Main.main(Main.java:55)
</Error-MSG>

                                    

Comments
EVALUATION

Short term fix being tracked with 6441871
                                     
2006-06-21
SUGGESTED FIX

A possible short term fix would be to handle CompletionFailure at the top level and turn it into a friendly error message; not the scary  OhMyGod-send-us-a-bug-report message.
                                     
2006-04-05
EVALUATION

Dealing with completion errors in JSR 269 in general
requires some additional amount of pondering.

Currently, completion errors can be thrown from any place
in the API.

We might not be able to deal with this issue before Mustang
beta 2 as we didn't recognize the scope of this problem earlier.
                                     
2006-02-23
SUGGESTED FIX

I think we need to rethink completion errors completely.

I have some sketchy ideas:

Make javac operate in two modes:

1. completion errors are fatal
2. completion errors are swallowed and errorneous objects
   are returned instead.

Mode 1 should be used for normal batch operation.  Mode 2 should
be used when in API mode, that is, called from annotation processor
or Tree API.

If this is confusing, don't worry, we will discuss it in person.
                                     
2006-02-23
EVALUATION

Note:  To run the test program I needed to declare this annotation type:
  @interface usethis { String value() default ""; }

The error that's reported is correct:  the processor really does create a bad
class file.  In round 1 it creates a class file named newfile.class
that is completely empty.  In round 2 it tries (as it should) to read
that empty class file, and fails.

The "bad class file" should, however, be reported as an error message
rather than as a javac crash.
                                     
2005-12-17



Hardware and Software, Engineered to Work Together