[2061/JDK1.5b2] Bad class file format error when using an annotation

Hi,

Trying to use annotations but getting an error:

Error: Bad class file format:
C:\Documents and Settings\Matt\IdeaProjects\Test\classes\TestAnnotations.class
Information: Compilation completed with 1 errors and 0 warnings


The annotation class is:

public @interface Transactional {
boolean autoCommit() default true;
}


the test class is:

public class TestAnnotations {
private int value;

public TestAnnotations(int value) {
this.value = value;
}

@Transactional public void setValue(int value) {
this.value = value;
}

public int getValue() {
return value;
}
}


The installation is:

-fresh install of #2061
-no imported settings
-fresh installation of JDK1.5beta2
-project language level set to 1.5

Couldn't find anything about this in the tracker. Is this a bug? Or
have I done something wrong (this is my first go at Pallada/JDK1.5)?

Regards,

Matt

/**

  • Created by IntelliJ IDEA.

  • User: Matt

  • Date: 30-May-2004

  • Time: 14:16:41

  • To change this template use File | Settings | File Templates.

*/
public @interface Transactional {
boolean autoCommit() default true;
}

/**

  • Created by IntelliJ IDEA.

  • User: Matt

  • Date: 30-May-2004

  • Time: 14:15:36

  • To change this template use File | Settings | File Templates.

*/
public class TestAnnotations {
private int value;

public TestAnnotations(int value) {
this.value = value;
}

@Transactional public void setValue(int value) {
this.value = value;
}

public int getValue() {
return value;
}
}

19 comments
Comment actions Permalink

Between some CAP builds, class files were not compatible, and you had to recompile your applications to run under a new build. This might be your problem.

0
Comment actions Permalink

Hi Keith,

Keith Lea wrote:

Between some CAP builds, class files were not compatible, and you had
to recompile your applications to run under a new build. This might
be your problem.


Do you mean EAP builds?

I installed #2061 fresh and wrote these files with it. They were never
compiled by a previous build of IDEA.

Regards,

Matt

0
Comment actions Permalink

No, I mean CAP pre-release builds of JDK 1.5. It looks like that's not your problem though, it's probably something wrong with IDEA.

0
Comment actions Permalink

Keith Lea wrote:

No, I mean CAP pre-release builds of JDK 1.5. It looks like that's not your problem though, it's probably something wrong with IDEA.

I wonder what could be wrong with IDEA making javac generate a class file it could not parse later?

--
Maxim Shafirov
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Comment actions Permalink

Maxim Shafirov (JetBrains) wrote:

Keith Lea wrote:

>> No, I mean CAP pre-release builds of JDK 1.5. It looks like that's not
>> your problem though, it's probably something wrong with IDEA.


I wonder what could be wrong with IDEA making javac generate a class
file it could not parse later?


Is there something I can add to my OP that will help figure this out?

Regards,

Matt

0
Comment actions Permalink

Matt Mower wrote:

Maxim Shafirov (JetBrains) wrote:

>> Keith Lea wrote:
>>
>>> No, I mean CAP pre-release builds of JDK 1.5. It looks like that's
>>> not your problem though, it's probably something wrong with IDEA.
>>
>>
>> I wonder what could be wrong with IDEA making javac generate a class
>> file it could not parse later?
>>


Is there something I can add to my OP that will help figure this out?

Regards,

Matt


Could you please validate that the problem persists (disappears) when compiling that code outside of the IDEA. I mean
compile the annotation class only and then the "client" class adding annotation class into the compiler's classpath.

--
Maxim Shafirov
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Comment actions Permalink

Maxim Shafirov (JetBrains) wrote:

Could you please validate that the problem persists (disappears) when
compiling that code outside of the IDEA. I mean compile the annotation
class only and then the "client" class adding annotation class into the
compiler's classpath.


I dropped into command prompt window, set path to JDK1.5-beta2, changed
to the directory where the java source files are located.

I was then able to do:

javac -g Transactional.java
javac -g TestAnnotations.java

without error. Using 'fc' I was able to verify that the .class files
were identical to those being generated building using IDEA.

Regards,

Matt

0
Comment actions Permalink

Hi,
-source -target javac parameters mismatch ? Those have changed between
jdk1.5b1 and jdk1.5b2.

Sincerely,
ToMiC


"Matt Mower" <matt@evectors.com> wrote in message
news:c9dhoo$cc3$1@is.intellij.net...

Maxim Shafirov (JetBrains) wrote:

Could you please validate that the problem persists (disappears) when
compiling that code outside of the IDEA. I mean compile the annotation
class only and then the "client" class adding annotation class into the
compiler's classpath.

>

>

I dropped into command prompt window, set path to JDK1.5-beta2, changed
to the directory where the java source files are located.

>

I was then able to do:

>

javac -g Transactional.java
javac -g TestAnnotations.java

>

without error. Using 'fc' I was able to verify that the .class files
were identical to those being generated building using IDEA.

>

Regards,

>

Matt



0
Comment actions Permalink

Toader Mihai Claudiu wrote:

Hi,
-source -target javac parameters mismatch ? Those have changed between
jdk1.5b1 and jdk1.5b2.


I'm not passing any additional parameters to javac (in the IDEA compiler
configuration dialog) and I suspect IDEA is not supplying any since the
.class files produced by IDEA and those produced on the cmd line using
javac -g were identical.

I'm still trying to work out, based upon Maxims comment, if this is
something I am doing wrong, a problem in IDEA, or an incompatibility
between IDEA and JDK1.5beta2.

Regards,

Matt

0
Comment actions Permalink

IDEA supplies additional parameters to the javac command line.
You will be able to see the exact command line that is executed if you enable logging in /bin/log.xml file by adding this: ]]>

--
Best regards,
Eugene Zhuravlev
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"


0
Comment actions Permalink

Eugene Zhuravlev (JetBrains) wrote:

IDEA supplies additional parameters to the javac command line.
You will be able to see the exact command line that is executed if you enable logging in <idea-home>/bin/log.xml file by adding
this:

<category name="#com.intellij.compiler">
<priority value="DEBUG"/>
<appender-ref ref="CONSOLE-ALL"/>
</category>


Here is the result of doing that:

2004-05-31 14:09:54,951 DEBUG -
ompiler.BackendCompilerWrapper - C:\Program
Files\Java\jdk1.5.0\bin\javaw.exe -Xmx128m -classpath C:\Program
Files\Java\jdk1.5.0\lib\tools.jar;C:\java\pallada2061\lib\idea_rt.jar
com.intellij.rt.compiler.JavacRunner "java version "1.5.0-beta2""
com.sun.tools.javac.Main -source 1.5 -verbose -classpath C:\Program
Files\Java\jdk1.5.0\jre\lib\charsets.jar;C:\Program
Files\Java\jdk1.5.0\jre\lib\deploy.jar;C:\Program
Files\Java\jdk1.5.0\jre\lib\javaws.jar;C:\Program
Files\Java\jdk1.5.0\jre\lib\jce.jar;C:\Program
Files\Java\jdk1.5.0\jre\lib\jsse.jar;C:\Program
Files\Java\jdk1.5.0\jre\lib\plugin.jar;C:\Program
Files\Java\jdk1.5.0\jre\lib\rt.jar;C:\Program
Files\Java\jdk1.5.0\jre\lib\ext\dnsns.jar;C:\Program
Files\Java\jdk1.5.0\jre\lib\ext\localedata.jar;C:\Program
Files\Java\jdk1.5.0\jre\lib\ext\sunjce_provider.jar;C:\Program
Files\Java\jdk1.5.0\jre\lib\ext\sunpkcs11.jar;C:\Documents and
Settings\Matt\IdeaProjects\Test\classes -sourcepath "" -d C:\Documents
and Settings\Matt\IdeaProjects\Test\classes -g -deprecation
@C:\DOCUME1\Matt\LOCALS1\Temp\javac43894.tmp

Regards,

Matt

0
Comment actions Permalink

I've done a little investigation and found out that the code generated by javac contradicts with the specification of the class file
format for annotations. So when IDEA parses the generated class file (according to the specification), you get the error.
It is unclear if this is a specification change or a javac bug introduced recently (this worked in previous JDK 1.5 beta builds).
The latest class file format specs I checked were unchanged in this area, so I suspect that this is a javac bug.
Submitted a bug to Sun.


--
Best regards,
Eugene Zhuravlev
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"


0
Comment actions Permalink

Eugene Zhuravlev (JetBrains) wrote:

I've done a little investigation and found out that the code generated by javac contradicts with the specification of the class file
format for annotations. So when IDEA parses the generated class file (according to the specification), you get the error.
It is unclear if this is a specification change or a javac bug introduced recently (this worked in previous JDK 1.5 beta builds).
The latest class file format specs I checked were unchanged in this area, so I suspect that this is a javac bug.
Submitted a bug to Sun.


Thanks Eugene.

Matt

0
Comment actions Permalink

Does it have an assigned bug number that I can track?

0
Comment actions Permalink

Here's the reply fom Sun:

Thank you for reporting this issue.

This issue is related to Bug ID: 5020908, which covers all the primitive types as well as boolean. Thank you for providing
additional information for our investigation.

You can review this bug and look for related issues on the Java Developer Connection Bug Database at:
http://developer.java.sun.com/developer/bugParade/
and
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5020908


--
Best regards,
Eugene Zhuravlev
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"

"Kohsuke Kawaguchi" <no_mail@jetbrains.com> wrote in message news:23901467.1086830380448.JavaMail.itn@is.intellij.net...

Does it have an assigned bug number that I can track?



0
Comment actions Permalink

The actual prblem is that this bug covers jsr-175/jsr-202 spec, and not
beta2 implementation. Thus without having a spec, we do not know how the
information is encoded in classfile.

"Eugene Zhuravlev (JetBrains)" <jeka@intellij.com> wrote in message
news:caunqm$7ht$1@is.intellij.net...

Here's the reply fom Sun:

>

Thank you for reporting this issue.

>

This issue is related to Bug ID: 5020908, which covers all the primitive

types as well as boolean. Thank you for providing

additional information for our investigation.

>

You can review this bug and look for related issues on the Java Developer

Connection Bug Database at:

http://developer.java.sun.com/developer/bugParade/
and
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5020908

>
>

--
Best regards,
Eugene Zhuravlev
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"

>

"Kohsuke Kawaguchi" <no_mail@jetbrains.com> wrote in message

news:23901467.1086830380448.JavaMail.itn@is.intellij.net...

Does it have an assigned bug number that I can track?

>
>


0
Comment actions Permalink

Hi!

I'n new to Java and IntelliJ (been vworking with DotNet for some years now), so I apologize in advance for any stupid questions I might ask, and please treat me as a complete newbie when answering.... :o)

I'm struggeling with the discussed issue on my machine, and I can't seem to get rid of all the "Bad class file format" -errors when compiling.

I'm supposed to extend som functionality in an existing project which was developed on JDK 1.4.2 and Tomcat 5.0.

I got this successfully up and running (without any compile errors) on my machine, and all was good until it crashed and I had to format and reinstall everything. (The crash had nothing to do with the JavaVM or IntelliJ by the way.)

Whith the main software up and running for the second time, I installed Tomcat 5.5 and JDK 1.5 and tried to run the project. As this didn't work I uninstalled Tomcat 5.5 and "downgraded" it to version 5.0. Now I was able to run and debug the project, and all seemed fine. But when I try to add or change a class-file and compile, the error-messages pops up! I've uninstalled JDK 1.5, installed 1.4.2 and set all references accordingly, but with no luck.

After fiddling around with this for a while, I found out the following pattern/workaround:
- first I change some class-file
- I build the project or module, and receive the error
- Then I have to rebuild the project (and receive a whole bunch of "Bad file format"-errors)
- At this point I can finally build the project or module without any errors


Could anyone please help me out here??

Regards YonZo

0
Comment actions Permalink

It sounds like you have some bad files on your classpath (either jars or class files). Have you tried deleting all locally generated code and rebuilding all using the target JDK? You may also have some version mismatches, but that usually generates a different error, but not sure about runtime versus compile time.

0

Please sign in to leave a comment.