Re: [Jastadd] [bug report] absence of AbstractWildcardType.createQualifiedAccess()

From: Na, Hyunik <hina_at_kaist.ac.kr>
Date: Thu, 3 May 2012 09:30:39 +0900

Hello Jesper,

 

Testing using your program and script does not produce the same result as my
script.

( It produces new error messages and NullPointer exceptions. )

 

In addition, it runs so fast that it is rather doubtful that it runs
correctly.

( it took only 20 seconds on my computer, but running

           java … JavaCompiler … _at_files

, that is compiling all the java files in a single invocation of the
JastAddJ compiler, took over 7 minutes.

Of course, my script is a lot slower: It took about an hour and 40 minutes.
)

 

Indeed, many messages look as if nothing is done.

For example, more than half of the messages look like:

 



### compiling
./com/sun/org/apache/xml/internal/security/exceptions/XMLSecurityRuntimeExce
ption.java

### result = 0, compiled
./com/sun/org/apache/xml/internal/security/exceptions/XMLSecurityRuntimeExce
ption.java

### compiling
./com/sun/org/apache/xml/internal/security/exceptions/XMLSecurityException.j
ava

### result = 0, compiled
./com/sun/org/apache/xml/internal/security/exceptions/XMLSecurityException.j
ava

### compiling
./com/sun/org/apache/xml/internal/security/exceptions/Base64DecodingExceptio
n.java

### result = 0, compiled
./com/sun/org/apache/xml/internal/security/exceptions/Base64DecodingExceptio
n.java



 

( Why isn’t there even a single “Loading .java file: …” message for each
test case? )

 

I thought about the reason of this difference.

I guess that the cause might be the static fields of the classes of
JastAddJ.

Each invocation of JavaCompiler.compile() in your script might not be run in
a completely “fresh” state of the compiler,

because some classes have static fields.

So, each invocation of JavaCompiler.compile() might be affected by earlier
invocations,

and the compiler might run into a state which is unreachable from a normal
execution.

( This is just a “guess”. I didn’t verify it. )

 

On the other hand, the results of “java … JavaCompiler … _at_files” and my
script coincide.

 

- Hyunik

 

From: Jesper qvist [mailto:jesper.oqvist_at_cs.lth.se]
Sent: Wednesday, May 02, 2012 12:53 AM
To: Na, Hyunik
Cc: jastadd_at_cs.lth.se
Subject: Re: [Jastadd] [bug report] absence of
AbstractWildcardType.createQualifiedAccess()

 

Hello Hyunik,

First of all thank you for the information! I should now be able to
reproduce your build conditions and also the original error.

Building OpenJDK seems to be a very useful test for JastAddJ. More bugs
found is a good thing, that means we can try to fix them!

I noticed that the build script you use is a bit slow. The reason is that
the JVM is restarted for each source file that is compiled. Considering the
large number of source files (7819 in openjdk-6-b24), you get a large
overhead for starting/stopping the host JVM (especially if you use a server
VM):

On 04/26/2012 04:02 AM, Na, Hyunik wrote:

rm -rf ./build/*

for i in $(find . -name *.java)

do

  echo "### compiling $i"

  java -cp $HOME/install/JastAddJ/Java1.5Backend JavaCompiler -verbose
-bootclasspath .:./build:$Openjdk16/build/linux-i586/classes -extdirs .
-classpath . -d build $i

  echo "### result = $?, compiled $i"

done

 


So if you want to build this faster, you could try to use the following
program I wrote. It seems to have sped up the build for me:

BatchCompiler.java:
============
import java.io.*;
import java.util.*;

public class BatchCompiler {

    public static void main(String[] args) {

        int fileList = -1;

        for (int i = 0; i < args.length; ++i) {
            if (args[i].startsWith("_at_")) {
                fileList = i;
                break;
            }
        }

        if (fileList == -1) {
            System.err.println("No file list argument found!");
            System.exit(1);
        }

        String[] compileArgs = new String[args.length];
        for (int i = 0; i < args.length; ++i) {
            if (i > fileList) {
                compileArgs[i-1] = args[i];
            } else {
                compileArgs[i] = args[i];
            }
        }

        try {
            Scanner scanner = new Scanner(new FileInputStream(
                        args[fileList].substring(1)));

            while (scanner.hasNextLine()) {
                String fileName = scanner.nextLine();
                compileArgs[args.length-1] = fileName;
                System.out.println("### compiling " + fileName);
                boolean result = false;
                try {
                    result = JavaCompiler.compile(compileArgs);
                } catch (Throwable t) {
                    t.printStackTrace();
                }
                System.out.println("### result = " +
                        (result ? 0 : 1) + ", compiled " + fileName);
            }
        } catch (IOException e) {
            e.printStackTrace();
            System.err.println("Batch compile aborted!");
            System.exit(1);
        }

    }
}
============

BatchCompiler simply invokes JastAddJ once for each line in the supplied
argument file, with the same command line arguments (except the argument
file option - it's difficult to explain this, hopefully my code is
clearer!).

I modified your build script to compile and invoke BatchCompiler:

============
#!/bin/sh

OPENJDK6=$HOME/jdk/openjdk6-b24
JASTADDJ=$HOME/svn/JastAddJ

echo "Preparing JastAddJ"
ant -f $JASTADDJ/Java1.5Backend/build.xml

find . -name '*.java' | grep -v 'BatchCompiler\.java' > files

rm -rf build
mkdir build

javac -cp $JASTADDJ/Java1.5Backend BatchCompiler.java
java -cp .:$JASTADDJ/Java1.5Backend BatchCompiler -verbose \
-bootclasspath .:./build:OPENJDK6/build/linux-amd64/classes \
-extdirs . -classpath . -d build _at_files 2>&1 | tee output.txt
============

It seems to compile the Java files much faster. Your results may vary.

/Jesper
Received on Thu May 03 2012 - 02:30:48 CEST

This archive was generated by hypermail 2.3.0 : Wed Apr 16 2014 - 17:19:06 CEST