Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4142972
Votes 0
Synopsis incompatibility problem between JDK1.2beta4 and JDK1.1.6
Category java:compiler
Reported Against 1.2beta4
Release Fixed
State 11-Closed, Not a Defect, bug
Priority: 2-High
Related Bugs
Submit Date 27-MAY-1998
Description





There is binary incompatibility problem between JDK1.2beta4G and 
JDK1.1.6.
The JDK1.2beta4G could not execute class compiled by JDK1.1.6 
that contains inner public class with private constructor.
It throws IllegalAccessError.


==== Here is the test demonstrating the bug ====
public class TestInner {

    public class InnerClassPublic {
    	public InnerClassPublic(){
    	}
    }
    public class InnerClassPrivate {
    	private InnerClassPrivate(){
    	}
    }
    public TestInner () {
    }
    public static void main(String[] args){
    	TestInner A = new TestInner();
    	InnerClassPublic B = A.a();
    	System.out.println("OKAY: InnerClassPublic created");
    	InnerClassPrivate C = A.b();
        System.out.println("OKAY: InnerClassPrivate created");
    }
    public InnerClassPublic a() {
    	return new InnerClassPublic();
    }
    public InnerClassPrivate b() {
    	return new InnerClassPrivate();
    }
}

==== Here is the output of the test ====

------- Under jdk1.1.6 ------- 
(  xxxxx@xxxxx  @/home/sda/temp/tests)71%/set/java/jdk1.1.6/solaris/bin/java -fullversion
java full version "JDK1.1.6N"
(  xxxxx@xxxxx  @/home/sda/temp/tests)72%/set/java/jdk1.1.6/solaris/bin/javac TestInner.java
(  xxxxx@xxxxx  @/home/sda/temp/tests)74%/set/java/jdk1.1.6/solaris/bin/java TestInner
OKAY: InnerClassPublic created
OKAY: InnerClassPrivate created

(  xxxxx@xxxxx  @/home/sda/temp/tests)70%java -fullversion
java full version "JDK-1.2beta4-G"
(  xxxxx@xxxxx  @/home/sda/temp/tests)75%java TestInner
OKAY: InnerClassPublic created
Exception in thread "main" java.lang.IllegalAccessError: try to access method TestInner$InnerClassPrivate.<init>(LTestInner;)V from class TestInner
	at TestInner.b(Compiled Code)
	at TestInner.main(Compiled Code)


------- Under jdk1.2-beta4-G ------- 
(  xxxxx@xxxxx  @/home/sda/temp/tests)104%java -fullversion
java full version "JDK-1.2beta4-G"
(  xxxxx@xxxxx  @/home/sda/temp/tests)105%javac TestInner.java
(  xxxxx@xxxxx  @/home/sda/temp/tests)106%java TestInner
OKAY: InnerClassPublic created
OKAY: InnerClassPrivate created

======================================================================
 Justification:
This is a compatibility-related bug

======================================================================
Work Around
N/A
Evaluation
I am handing this off to   xxxxx@xxxxx  .  I suspect that this is not actually a bug, but the result of a bug from 1.1.6 being fixed in 1.2 combined with stronger access checking.

  xxxxx@xxxxx   1998-05-27

Versions of javac prior to 1.2beta4 did not generate an access method
for private constructors accessed from within another class.  The code
that was generated in this case would not pass the VM-level access checks.
These checks were suppressed for code loaded from the classpath in versions
of the VM prior to 1.2beta3, thus only code executed as an applet would fail.

This is documented behavior for 1.2 -- see "Runtime Incompatibilities in
Version 1.2" in http://java.sun.com/products/jdk/1.2/compatibility.html.

The workaround is to either recompile the code with 1.2beta4 or later, or to
turn off verification in the VM:  java -Xverify:none (or -Xverify:remote)

  xxxxx@xxxxx   1998-05-27

Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang