JDK-4054010 : Modification of a private field in another class allowed by 1.1.1 VM.
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 1.1.1
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.5.1
  • CPU: generic
  • Submitted: 1997-05-22
  • Updated: 1997-07-22
  • Resolved: 1997-07-22
Related Reports
Duplicate :  
Relates :  
Description
allan.jacobs@Eng 1997-05-22

The JCK-111a test putfield01902 tests whether a class can set the
private field Integer.value.  The class returns with exit code 0
instead of aborting.  This is true for both green and native threads,
JIT enabled and disabled, on both Sparc and x86 Solaris systems.

algol% cat /net/mulder/export/mulder3/JCK-111a/tests/vm/instr/putfieldputfield019/putfield01902/putfield01902.jasm
package javasoft/sqe/tests/vm/putfield/putfield019/putfield01902;

public class  putfield01902 {

public static Method run:"([Ljava/lang/String;Ljava/io/PrintStream;)I"
	stack 3 locals 3
{
	new class java/lang/Integer;  dup;
	iconst_0;
	invokespecial	java/lang/Integer.<init>:"(I)V";
	dup;
	iconst_0/*STATUS_PASSED*/; //negative test failed
	putfield	java/lang/Integer.value:I;
	getfield	java/lang/Integer.value:I;
	ireturn;
}

public static Method main:"([Ljava/lang/String;)V"
	stack 2 locals 1
{
	aload_0;
	getstatic		java/lang/System.out:"Ljava/io/PrintStream;";
	invokestatic	run:"([Ljava/lang/String;Ljava/io/PrintStream;)I";
	invokestatic	java/lang/System.exit:"(I)V";
	return;
}

} 

With native threads:

algol% printenv CLASSPATH
.:/net/mulder/export/mulder3/JCK-111a/classes
algol% which java
/usr/java/bin/java
algol% java -fullversion
java full version "jvm111_20n:97.05.20"
algol% java -Djava.compiler=sunwjit -verify \ javasoft.sqe.tests.vm.putfield.putfield019.putfield01902.putfield01902
algol% echo $status
0
algol% java -Djava.compiler=none -verify \ javasoft.sqe.tests.vm.putfield.putfield019.putfield01902.putfield01902
algol% echo $status
0

After changing the JDK to green threads:

algol% which java
/usr/java/bin/java
algol% java -fullversion
java full version "jvm111_20g:97.05.20"
algol% java -Djava.compiler=sunwjit -verify \ javasoft.sqe.tests.vm.putfield.putfield019.putfield01902.putfield01902
algol% echo $status
0
algol% java -Djava.compiler=none -verify \ javasoft.sqe.tests.vm.putfield.putfield019.putfield01902.putfield01902
algol% echo $status
0

On an x86, the situation is identical.  First with native threads:

x86-sirius% printenv CLASSPATH
.:/net/mulder/export/mulder3/JCK-111a/classes
x86-sirius% which java
/usr/java/bin/java
x86-sirius% java -fullversion
java full version "jvm111_20n:97.05.20"
x86-sirius% java -Djava.compiler=sunwjit -verify \ javasoft.sqe.tests.vm.putfield.putfield019.putfield01902.putfield01902
x86-sirius% echo $status
0
x86-sirius% java -Djava.compiler=none -verify \ javasoft.sqe.tests.vm.putfield.putfield019.putfield01902.putfield01902
x86-sirius% echo $status
0

Finally, on an x86 with green threads:

x86-sirius% which java
/usr/java/bin/java
x86-sirius% java -fullversion
java full version "jvm111_20g:97.05.20"
x86-sirius% java -Djava.compiler=sunwjit -verify \ javasoft.sqe.tests.vm.putfield.putfield019.putfield01902.putfield01902
x86-sirius% echo $status
0
x86-sirius% java -Djava.compiler=none -verify \ javasoft.sqe.tests.vm.putfield.putfield019.putfield01902.putfield01902
x86-sirius% echo $status
0

Comments
EVALUATION Sun's JVM allows classes loaded along CLASSPATH to override access protections. This is because old versions of "javac -O" would incorrectly inline references to inaccessible members. We intend to fix in 1.2, but this needs to be the case for backwards compatibility (esp HJ). Note that such illegal code, when loaded via a ClassLoader, will fail with an IllegalAccessError. nakul.saraiya@Eng 1997-06-06
06-06-1997