Difference between revisions of "DealingWithJava5CompilerIssues"

From Protege Wiki
Jump to: navigation, search
(Created page with 'Because apple has not yet moved to Java 6, the Protege team has remained with the Java 5 development platform. Since this is an old platform that is coming close to its end of l...')
 
Line 1: Line 1:
Because apple has not yet moved to Java 6, the Protege team has remained with the Java 5 development platform.  Since this is an old platform that is coming close to its end of life there are bugs that have been fixed in Java 6 but not in Java 5.  When I was working on solving this problem, I had no idea how  to isolate the problem.  In the end I got lucky and found an approach that worked so I thought that I would report it here.
+
Because apple has not yet moved to Java 6, the Protege team has remained with the Java 5 development platform.  Since this is an old platform that is coming close to its end of life there are bugs that have been fixed in Java 6 but not in Java 5.  There are at least two of  these Java 5 compiler  bugs  that have given the Protege developers trouble.  The first of these involved an annotation in the wrong part of the java code (eclipse liked it but Sun's java compiler  did not).  The second of these was much more difficult to find and fix and for a while I was in despair considering that we might be forced to abandon the Sun Java platform in favor of  Jikes.
 +
When I was working on solving this problem, I had no idea how  to isolate the source of the problem.  In the end I got lucky and found an approach that worked so I thought that I would report it here.  This is the second time we have had this type of problem and if it ever happens again I hope that this page can help you find a solution.
  
 
To see the problem, checkout [http://smi-protege/repos/protege/protege4/protege-standalone/branches/protege4_1_port] at revision 14332 and run<pre>
 
To see the problem, checkout [http://smi-protege/repos/protege/protege4/protege-standalone/branches/protege4_1_port] at revision 14332 and run<pre>
 
     ant clean equinox
 
     ant clean equinox
 
</pre>
 
</pre>
 +
If you do this with a Java 6 compiler there will be no problem.
 
If you do this with apple's Java 5 compiler you will see the error
 
If you do this with apple's Java 5 compiler you will see the error
 
<pre>
 
<pre>
Line 12: Line 14:
 
     [javac] at com.sun.tools.javac.comp.Lower.access(Lower.java:1048)
 
     [javac] at com.sun.tools.javac.comp.Lower.access(Lower.java:1048)
 
</pre>
 
</pre>
If you do this on one of the Java 5 sun compiler's you will see an AssertionError with a similar stack.
+
If you do this on one of the Java 5 sun compiler's you will see an AssertionError with a different stack:
 +
<pre>
 +
    [javac] An exception has occurred in the compiler (1.5.0_17). 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.
 +
    [javac] java.lang.AssertionError
 +
    [javac] at com.sun.tools.javac.comp.Lower.access(Lower.java:955)
 +
    [javac] at com.sun.tools.javac.comp.Lower.access(Lower.java:1048)
 +
    [javac] at com.sun.tools.javac.comp.Lower.makeOwnerThis(Lower.java:1379)
 +
    [javac] at com.sun.tools.javac.comp.Lower.access(Lower.java:1019)
 +
</pre>
 +
 
 +
It is  not at all clear at this point how  to pinpoint the problem.  It was  not hard to determine which svn revisions were involved. The problem occurred between revisions 14299 and 14300.  However several files changed in that period:
 +
<pre>
 +
[tredmond@Andromeda owleditor]$ svn diff --summarize -r 14299:14300
 +
M      plugins/org.protege.editor.owl/src/org/protege/editor/owl/model/OWLWorkspace.java
 +
M      plugins/org.protege.editor.owl/src/org/protege/editor/owl/model/entity/CustomOWLEntityFactory.java
 +
M      plugins/org.protege.editor.owl/src/org/protege/editor/owl/model/entity/OWLEntityFactory.java
 +
M      plugins/org.protege.editor.owl/src/org/protege/editor/owl/model/hierarchy/IndividualsByInferredTypeHierarchyProvider.java
 +
M      plugins/org.protege.editor.owl/src/org/protege/editor/owl/model/hierarchy/cls/InferredOWLClassHierarchyProvider.java
 +
M      plugins/org.protege.editor.owl/src/org/protege/editor/owl/model/hierarchy/OWLObjectHierarchyProvider.java
 +
M      plugins/org.protege.editor.owl/src/org/protege/editor/owl/model/hierarchy/AbstractOWLPropertyHierarchyProvider.java
 +
M      plugins/org.protege.editor.owl/src/org/protege/editor/owl/model/hierarchy/OWLOntologyHierarchyProvider.java
 +
M      plugins/org.protege.editor.owl/src/org/protege/editor/owl/model/hierarchy/OWLObjectPropertyHierarchyProvider.java
 +
M      plugins/org.protege.editor.owl/src/org/protege/editor/owl/model/hierarchy/OWLDataPropertyHierarchyProvider.java
 +
M      plugins/org.protege.editor.owl/src/org/protege/editor/owl/model/hierarchy/OWLAnnotationPropertyHierarchyProvider.java
 +
M      plugins/org.protege.editor.owl/src/org/protege/editor/owl/model/hierarchy/IndividualsByTypeHierarchyProvider.java
 +
M      plugins/org.protege.editor.owl/src/org/protege/editor/owl/model/hierarchy/AbstractSuperClassHierarchyProvider.java
 +
M      plugins/org.protege.editor.owl/src/org/protege/editor/owl/model/hierarchy/AbstractOWLObjectHierarchyProvider.java
 +
M      plugins/org.protege.editor.owl/src/org/protege/editor/owl/model/hierarchy/AssertedClassHierarchyProvider2.java
 +
M      plugins/org.protege.editor.owl/src/org/protege/editor/owl/ui/OWLEntitySelectorPanel.java
 +
M      plugins/org.protege.editor.owl/src/org/protege/editor/owl/ui/tree/OWLObjectTree.java
 +
M      plugins/org.protege.editor.owl/src/org/protege/editor/owl/ui/tree/OWLModelManagerTree.java
 +
M      plugins/org.protege.editor.owl/src/org/protege/editor/owl/ui/renderer/OWLIconProviderImpl.java
 +
M      plugins/org.protege.editor.owl/src/org/protege/editor/owl/ui/view/annotationproperty/OWLAnnotationPropertyHierarchyViewComponent.java
 +
M      plugins/org.protege.editor.owl/src/org/protege/editor/owl/ui/frame/OWLAnnotationFrameSection.java
 +
A      plugins/org.protege.editor.owl/icons/property.annotation.addsib.png
 +
A      plugins/org.protege.editor.owl/icons/property.annotation.addsub.png
 +
M      plugins/org.semanticweb.owl.owlapi/lib/owlapi-bin.jar
 +
[tredmond@Andromeda owleditor]$
 +
</pre>
 +
This is a lot of code to work through and even when I was down to one class it took a bit of work to finish.  So working through this would be possible but pretty hard.  I tried using the -v option to the ant process but as it turned out this pointed me  to the wrong problem.  Ant -v pointed me to the RDFXMLRenderingViewComponent class which was not the cause of the problem. What I didn't yet know was that I needed to run the java compiler directly with the -verbose option.
 +
 
 +
So I was playing with running the java compiler directly from the command  line and at some point I tried the lucky sequence  of commands
 +
<pre>
 +
  CP=../../Protege/bundles/org.protege.common.jar
 +
  CP=${CP}:../../Protege/bundles/org.protege.editor.core.application.jar
 +
  CP=${CP}:../../Protege/plugins/org.semanticweb.owl.owlapi.jar
 +
  CP=${CP}:../build/lib/log4j.jar
 +
  CP=${CP}:../../Protege/org.eclipse.osgi.jar
 +
  CP=${CP}:../../Protege/bundles/org.eclipse.equinox.registry.jar
 +
  javac -verbose -d ../build/classes -classpath ${CP}  `find org -name "*.java"`
 +
</pre>
 +
You would have to do a bit of work to get the above to work but if you really need to I know you could set it up.  It is much harder to do that running ant with the -v option but it pointed me to the correct file.  With the -verbose option I could see what the compiler was doing right before it  died:
 +
<pre>
 +
...
 +
[wrote ../build/classes/org/protege/editor/owl/ui/view/annotationproperty/AbstractOWLAnnotationPropertyViewComponent.class]
 +
[checking org.protege.editor.owl.ui.view.annotationproperty.OWLAnnotationPropertyHierarchyViewComponent]
 +
An exception has occurred in the compiler (1.5.0_16). 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.AssertionError
 +
at com.sun.tools.javac.comp.Lower.access(Lower.java:955)
 +
at com.sun.tools.javac.comp.Lower.access(Lower.java:1048)
 +
at com.sun.tools.javac.comp.Lower.makeOwnerThis(Lower.java:1379)
 +
at com.sun.tools.javac.comp.Lower.access(Lower.java:1019)
 +
</pre>
 +
This pointed me to the OWLAnnotationPropertyHierarchyViewComponent class.  I had no idea at this point whether the problem was really with the RDFXMLRenderingViewComponent  class or the OWLAnnotationPropertyHierarchyViewComponent class.  I knew I was on the right track when I emptied  the OWLAnnotationPropertyHierarchyViewComponent class, added the minimal  amount of code to get it to compile in the ide and then ran the ant script.  The ant script was now able to compile the code!  I was close!  Then I did  a binary search of changes through this  class to narrow  the problem.  Even when I was down to the five lines of code that was causing the problem it took me a while before I figured out the fix.
 +
 
 +
Hopefully knowing the sequence of steps will help you!

Revision as of 00:07, May 30, 2009

Because apple has not yet moved to Java 6, the Protege team has remained with the Java 5 development platform. Since this is an old platform that is coming close to its end of life there are bugs that have been fixed in Java 6 but not in Java 5. There are at least two of these Java 5 compiler bugs that have given the Protege developers trouble. The first of these involved an annotation in the wrong part of the java code (eclipse liked it but Sun's java compiler did not). The second of these was much more difficult to find and fix and for a while I was in despair considering that we might be forced to abandon the Sun Java platform in favor of Jikes. When I was working on solving this problem, I had no idea how to isolate the source of the problem. In the end I got lucky and found an approach that worked so I thought that I would report it here. This is the second time we have had this type of problem and if it ever happens again I hope that this page can help you find a solution.

To see the problem, checkout [1] at revision 14332 and run
    ant clean equinox

If you do this with a Java 6 compiler there will be no problem. If you do this with apple's Java 5 compiler you will see the error

    [javac] An exception has occurred in the compiler (1.5.0_16). 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.
    [javac] java.lang.NullPointerException
    [javac] 	at com.sun.tools.javac.tree.TreeMaker.Ident(TreeMaker.java:413)
    [javac] 	at com.sun.tools.javac.comp.Lower.access(Lower.java:956)
    [javac] 	at com.sun.tools.javac.comp.Lower.access(Lower.java:1048)

If you do this on one of the Java 5 sun compiler's you will see an AssertionError with a different stack:

    [javac] An exception has occurred in the compiler (1.5.0_17). 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.
    [javac] java.lang.AssertionError
    [javac] 	at com.sun.tools.javac.comp.Lower.access(Lower.java:955)
    [javac] 	at com.sun.tools.javac.comp.Lower.access(Lower.java:1048)
    [javac] 	at com.sun.tools.javac.comp.Lower.makeOwnerThis(Lower.java:1379)
    [javac] 	at com.sun.tools.javac.comp.Lower.access(Lower.java:1019)

It is not at all clear at this point how to pinpoint the problem. It was not hard to determine which svn revisions were involved. The problem occurred between revisions 14299 and 14300. However several files changed in that period:

[tredmond@Andromeda owleditor]$ svn diff --summarize -r 14299:14300
M       plugins/org.protege.editor.owl/src/org/protege/editor/owl/model/OWLWorkspace.java
M       plugins/org.protege.editor.owl/src/org/protege/editor/owl/model/entity/CustomOWLEntityFactory.java
M       plugins/org.protege.editor.owl/src/org/protege/editor/owl/model/entity/OWLEntityFactory.java
M       plugins/org.protege.editor.owl/src/org/protege/editor/owl/model/hierarchy/IndividualsByInferredTypeHierarchyProvider.java
M       plugins/org.protege.editor.owl/src/org/protege/editor/owl/model/hierarchy/cls/InferredOWLClassHierarchyProvider.java
M       plugins/org.protege.editor.owl/src/org/protege/editor/owl/model/hierarchy/OWLObjectHierarchyProvider.java
M       plugins/org.protege.editor.owl/src/org/protege/editor/owl/model/hierarchy/AbstractOWLPropertyHierarchyProvider.java
M       plugins/org.protege.editor.owl/src/org/protege/editor/owl/model/hierarchy/OWLOntologyHierarchyProvider.java
M       plugins/org.protege.editor.owl/src/org/protege/editor/owl/model/hierarchy/OWLObjectPropertyHierarchyProvider.java
M       plugins/org.protege.editor.owl/src/org/protege/editor/owl/model/hierarchy/OWLDataPropertyHierarchyProvider.java
M       plugins/org.protege.editor.owl/src/org/protege/editor/owl/model/hierarchy/OWLAnnotationPropertyHierarchyProvider.java
M       plugins/org.protege.editor.owl/src/org/protege/editor/owl/model/hierarchy/IndividualsByTypeHierarchyProvider.java
M       plugins/org.protege.editor.owl/src/org/protege/editor/owl/model/hierarchy/AbstractSuperClassHierarchyProvider.java
M       plugins/org.protege.editor.owl/src/org/protege/editor/owl/model/hierarchy/AbstractOWLObjectHierarchyProvider.java
M       plugins/org.protege.editor.owl/src/org/protege/editor/owl/model/hierarchy/AssertedClassHierarchyProvider2.java
M       plugins/org.protege.editor.owl/src/org/protege/editor/owl/ui/OWLEntitySelectorPanel.java
M       plugins/org.protege.editor.owl/src/org/protege/editor/owl/ui/tree/OWLObjectTree.java
M       plugins/org.protege.editor.owl/src/org/protege/editor/owl/ui/tree/OWLModelManagerTree.java
M       plugins/org.protege.editor.owl/src/org/protege/editor/owl/ui/renderer/OWLIconProviderImpl.java
M       plugins/org.protege.editor.owl/src/org/protege/editor/owl/ui/view/annotationproperty/OWLAnnotationPropertyHierarchyViewComponent.java
M       plugins/org.protege.editor.owl/src/org/protege/editor/owl/ui/frame/OWLAnnotationFrameSection.java
A       plugins/org.protege.editor.owl/icons/property.annotation.addsib.png
A       plugins/org.protege.editor.owl/icons/property.annotation.addsub.png
M       plugins/org.semanticweb.owl.owlapi/lib/owlapi-bin.jar
[tredmond@Andromeda owleditor]$ 

This is a lot of code to work through and even when I was down to one class it took a bit of work to finish. So working through this would be possible but pretty hard. I tried using the -v option to the ant process but as it turned out this pointed me to the wrong problem. Ant -v pointed me to the RDFXMLRenderingViewComponent class which was not the cause of the problem. What I didn't yet know was that I needed to run the java compiler directly with the -verbose option.

So I was playing with running the java compiler directly from the command line and at some point I tried the lucky sequence of commands

  CP=../../Protege/bundles/org.protege.common.jar
  CP=${CP}:../../Protege/bundles/org.protege.editor.core.application.jar
  CP=${CP}:../../Protege/plugins/org.semanticweb.owl.owlapi.jar
  CP=${CP}:../build/lib/log4j.jar
  CP=${CP}:../../Protege/org.eclipse.osgi.jar 
  CP=${CP}:../../Protege/bundles/org.eclipse.equinox.registry.jar
  javac -verbose -d ../build/classes -classpath ${CP}  `find org -name "*.java"`

You would have to do a bit of work to get the above to work but if you really need to I know you could set it up. It is much harder to do that running ant with the -v option but it pointed me to the correct file. With the -verbose option I could see what the compiler was doing right before it died:

...
[wrote ../build/classes/org/protege/editor/owl/ui/view/annotationproperty/AbstractOWLAnnotationPropertyViewComponent.class]
[checking org.protege.editor.owl.ui.view.annotationproperty.OWLAnnotationPropertyHierarchyViewComponent]
An exception has occurred in the compiler (1.5.0_16). 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.AssertionError
	at com.sun.tools.javac.comp.Lower.access(Lower.java:955)
	at com.sun.tools.javac.comp.Lower.access(Lower.java:1048)
	at com.sun.tools.javac.comp.Lower.makeOwnerThis(Lower.java:1379)
	at com.sun.tools.javac.comp.Lower.access(Lower.java:1019)

This pointed me to the OWLAnnotationPropertyHierarchyViewComponent class. I had no idea at this point whether the problem was really with the RDFXMLRenderingViewComponent class or the OWLAnnotationPropertyHierarchyViewComponent class. I knew I was on the right track when I emptied the OWLAnnotationPropertyHierarchyViewComponent class, added the minimal amount of code to get it to compile in the ide and then ran the ant script. The ant script was now able to compile the code! I was close! Then I did a binary search of changes through this class to narrow the problem. Even when I was down to the five lines of code that was causing the problem it took me a while before I figured out the fix.

Hopefully knowing the sequence of steps will help you!