Bug 39959 - AJC Compiler generates invalid class files under certain circunstances.
Summary: AJC Compiler generates invalid class files under certain circunstances.
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P2 critical (vote)
Target Milestone: 1.1.1   Edit
Assignee: Mik Kersten CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-07-11 16:01 EDT by Igor Hjelmstrom Vinhas Ribeiro CLA
Modified: 2003-08-28 06:39 EDT (History)
3 users (show)

See Also:


Attachments
PART 1 of 3 - Sample code and scripts to demonstrate ajc compiler bug. (778.08 KB, application/octet-stream)
2003-07-11 16:09 EDT, Igor Hjelmstrom Vinhas Ribeiro CLA
no flags Details
PART 2 of 3 - Sample code and scripts to demonstrate ajc compiler bug. (774.06 KB, application/octet-stream)
2003-07-11 16:11 EDT, Igor Hjelmstrom Vinhas Ribeiro CLA
no flags Details
PART 3 of 3 - Sample code and scripts to demonstrate ajc compiler bug. (51.35 KB, application/octet-stream)
2003-07-11 16:12 EDT, Igor Hjelmstrom Vinhas Ribeiro CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Igor Hjelmstrom Vinhas Ribeiro CLA 2003-07-11 16:01:33 EDT
I made a package (I will attach it to this bug with the name bug.zip) which
shows a sample Java program that correctly runs when compiled with javac and
have classloading problems every time it is compiled with ajc.

Please see the file README.TO.DEMONSTRATE.BUG inside the bug.zip archive for
detailed (although simple) instructions on reproducing the bug.

There are two shell scripts attached to make things easier.

Please keep me informed of the status of this issue.
Comment 1 Igor Hjelmstrom Vinhas Ribeiro CLA 2003-07-11 16:09:48 EDT
Created attachment 5431 [details]
PART 1 of 3 - Sample code and scripts to demonstrate ajc compiler bug.

See the contained file README.TO.DEMONSTRATE.BUG for information.
Comment 2 Igor Hjelmstrom Vinhas Ribeiro CLA 2003-07-11 16:11:36 EDT
Created attachment 5432 [details]
PART 2 of 3 - Sample code and scripts to demonstrate ajc compiler bug.

See the contained file README.TO.DEMONSTRATE.BUG for information
Comment 3 Igor Hjelmstrom Vinhas Ribeiro CLA 2003-07-11 16:12:56 EDT
Created attachment 5433 [details]
PART 3 of 3 - Sample code and scripts to demonstrate ajc compiler bug.

See the contained file README.TO.DEMONSTRATE.BUG for information.
Comment 4 Igor Hjelmstrom Vinhas Ribeiro CLA 2003-07-11 16:14:09 EDT
Sorry for the big files. I wanted to make something easy to reproduce and
self-contained.
Comment 5 Jim Hugunin CLA 2003-07-22 19:44:34 EDT
What version of the compiler are you using?  I can't reproduce this with the 
1.1.0 released compiler.  When I run compile_and_test_class_with_ajc, I 
see "The test case worked!".  Are you using an older version of ajc?
Comment 6 Igor Hjelmstrom Vinhas Ribeiro CLA 2003-07-23 09:02:40 EDT
I am using j2sdk1.4.1_01 and I just noticed something which might help you to
reproduce the bug:

The JAVA_HOME environment variable must be set to
<place-where-java-is-located>/j2sdk1.4.1_01
for the problem to appear.

* The version I am using is really 1.1.0...
* You should have seen an exception instead of the "The test case worked!" message.
* If you still cannot reproduce the bug, I will happily provide access to my
system to show it if you wish.
Comment 7 Jim Hugunin CLA 2003-07-23 12:32:40 EDT
I still can't duplicate this bug.  The only difference I can see with our 
systems is that I'm running under Windows XP instead of Linux.  My detailed 
Java version info is:

C:\aspectj\scratch\bug>java -version
java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)

Under this configuration I can't duplicate this bug.  I'm cc'ing this to 
George Harley who I know has easy access to both Windows and Linux boxes to 
see if he has better luck reproducing it on one or both of those systems.
Comment 8 George Harley CLA 2003-07-23 13:13:34 EDT
OK, I can look at this one tomorrow (Thursday 24th July). My Linux Java is :
java version "1.4.1_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_05-b01)
Java HotSpot(TM) Client VM (build 1.4.1_05-b01, mixed mode)
Comment 9 Jim Hugunin CLA 2003-07-23 13:35:13 EDT
Raising to P2 to be sure that we investigate before 1.1.1 release.  
Investigation may result either in a fix or a lowering of priority.
Comment 10 George Harley CLA 2003-07-23 13:43:59 EDT
I couldn't resist trying to see if the error showed up for me before I left the 
office for the day. Using the test case supplied in the zip files all went OK 
when it was compiled and run with the 1.4.1 JDK. However, when I compiled it 
with the 1.1.0 ajc and ran it on the 1.4.1 JVM I got the following ...

Exception in thread "main" java.lang.NoClassDefFoundError: 
org/apache/xerces/parsers/AbstractDOMParser
        at testcase.ShowBug.main(ShowBug.java:49)

I saw the same runtime behaviour when running the class with a 1.3.1 JVM.

Like I said, I can look into this further tomorrow. Is the above exception what 
you are seeing in your environment ?
Comment 11 Jim Hugunin CLA 2003-07-23 13:51:33 EDT
George, I don't want to keep you any later tonight, but tommorrow could you do 
the same test on a Windows XP box to verify if this is a Linux-only bug or if 
I'm somehow special in not being able to reproduce it?
Comment 12 Igor Hjelmstrom Vinhas Ribeiro CLA 2003-07-23 14:13:19 EDT
   The exception reported by George is exactly what I got running the
bug-reproducer now. However, In the original environment (I am working in the
development of software which source code I unfortunately cannot disclose) the
compiler generated invalid class files some times.

   Again, if any of you need a test environment in which the bug shows up every
time access the http://pinheiros.ic.unicamp.br:40000 address in any java-enabled
browser and mail me for the password - I have a X session (inside VNC) laying there.
Comment 13 George Harley CLA 2003-07-23 17:47:35 EDT
The test case is failing for me on Windows XP as well but in a different way to 
the previously observed Linux failure. 

On Windows XP with a 1.4.1_02 Java and a 1.1.0 AspectJ when I ran the ajc script 
supplied in the test case zip I got what looked like a silent failure : the 
script was launched and then just returned without any information. That is, no 
success message and no error messages. With the addition of a print statement or 
two to the script it became clear that the call to ajc never completed and 
caused the entire script to exit before any attempt was made to run the class. I 
added the -verbose flag to a command line call to ajc (compiling 
testcase\ShowBug.java, the same source file as specified in the test script) and 
got the following ...

C:\39959\bug>ajc -verbose testcase\ShowBug.java
zipfile classpath entry does not exist: c:\sun-jdk-141-02\jre\lib\i18n.jar
directory classpath entry does not exist: c:\sun-jdk-141-02\jre\classes
compiling C:\39959\bug\testcase\ShowBug.java
compiling C:\39959\bug\.\util\xml\Item.java
compiling C:\39959\bug\.\util\xml\AttributeNotFoundException.java
compiling C:\39959\bug\.\util\xml\ChildNotFoundException.java
compiling C:\39959\bug\.\util\xml\ItemList.java
compiling C:\39959\bug\.\util\xml\TextNotFoundAtBeginningException.java
compiling C:\39959\bug\.\util\xml\NoSuchItemRuntimeException.java
weaving
might need to weave [UnwovenClassFile(C:\39959\bug\testcase\ShowBug$1.class, tes
tcase.ShowBug$1), UnwovenClassFile(C:\39959\bug\testcase\ShowBug.class, testcase
.ShowBug), UnwovenClassFile(C:\39959\bug\.\util\xml\Item.class, util.xml.Item),
UnwovenClassFile(C:\39959\bug\.\util\xml\AttributeNotFoundException.class, util.
xml.AttributeNotFoundException), UnwovenClassFile(C:\39959\bug\.\util\xml\ChildN
otFoundException.class, util.xml.ChildNotFoundException), UnwovenClassFile(C:\39
959\bug\.\util\xml\ItemList.class, util.xml.ItemList), UnwovenClassFile(C:\39959
\bug\.\util\xml\TextNotFoundAtBeginningException.class, util.xml.TextNotFoundAtB
eginningException), UnwovenClassFile(C:\39959\bug\.\util\xml\NoSuchItemRuntimeEx
ception.class, util.xml.NoSuchItemRuntimeException)](world=false)

(For the above the CLASSPATH in my environment was C:\aspectj1.1.
0-final\lib\aspectjrt.jar;.)

In another XP window with a 1.3.1_08 Java (and identical environmental 
CLASSPATH) I got the very same behaviour when running the testcase script 
(silent exit from the script somewhere in the ajc call). I repeated the ajc 
command with verbose and saw the following ...

C:\39959\bug>ajc -verbose testcase\ShowBug.java
directory classpath entry does not exist: c:\sun-jdk-131-08\jre\classes
compiling C:\39959\bug\testcase\ShowBug.java
compiling C:\39959\bug\.\util\xml\Item.java
compiling C:\39959\bug\.\util\xml\AttributeNotFoundException.java
compiling C:\39959\bug\.\util\xml\ChildNotFoundException.java
compiling C:\39959\bug\.\util\xml\ItemList.java
compiling C:\39959\bug\.\util\xml\TextNotFoundAtBeginningException.java
compiling C:\39959\bug\.\util\xml\NoSuchItemRuntimeException.java
weaving
might need to weave [UnwovenClassFile(C:\39959\bug\testcase\ShowBug$1.class, tes
tcase.ShowBug$1), UnwovenClassFile(C:\39959\bug\testcase\ShowBug.class, testcase
.ShowBug), UnwovenClassFile(C:\39959\bug\.\util\xml\Item.class, util.xml.Item),
UnwovenClassFile(C:\39959\bug\.\util\xml\AttributeNotFoundException.class, util.
xml.AttributeNotFoundException), UnwovenClassFile(C:\39959\bug\.\util\xml\ChildN
otFoundException.class, util.xml.ChildNotFoundException), UnwovenClassFile(C:\39
959\bug\.\util\xml\ItemList.class, util.xml.ItemList), UnwovenClassFile(C:\39959
\bug\.\util\xml\TextNotFoundAtBeginningException.class, util.xml.TextNotFoundAtB
eginningException), UnwovenClassFile(C:\39959\bug\.\util\xml\NoSuchItemRuntimeEx
ception.class, util.xml.NoSuchItemRuntimeException)](world=false)

In both windows the ajc compile step did actually produce a .class file and when 
it was run the following was returned ...

C:\39959\bug>java testcase.ShowBug
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xerces/par
sers/AbstractDOMParser
        at testcase.ShowBug.main(ShowBug.java:49)

i.e. identical to the final outcome seen earlier on Linux.

Jim, are you using an ajc from out of the CVS HEAD ? Maybe this has been fixed 
post-1.1.0 ?
Comment 14 Mik Kersten CLA 2003-07-29 07:00:49 EDT
This problem occurred when a command line compile did not specify a "-
classpath" option.  In that case BuildArgParser loaded System.getProperty
("java.class.path").  However, in the launch script aspectjtools.jar is 
already added to the VM's classpath.  We remove all occurrences 
of "aspectjtools.jar" from the detected classpath.  This should enable 
bootstrapping ajc.