-
Bug
-
Resolution: Fixed
-
P3
-
1.2.0
-
1.2fcs
-
sparc
-
solaris_2.5
-
Not verified
Name: szC45993 Date: 08/19/97
JDK1.2H throws different exception in certain cases as compared with JDK1.1.4G.
JDK1.1.4G in most cases throws more specific exceptions when JDK1.2H throws
just java.lang.ClassFormatError in many cases which seems not in conformance
with JVM specifications. As result several JCK tests fail for JDK1.2H:
vm/constantpool/ClassInterf/ClassInterf006/ClassInterf00601
vm/constantpool/ClassInterf/ClassInterf012/ClassInterf01201
vm/constantpool/ClassInterf/ClassInterf038/ClassInterf03801
vm/constantpool/ClassInterf/ClassInterf041/ClassInterf04101
vm/constantpool/ClassInterf/ClassInterf042/ClassInterf04201
vm/constantpool/ClassInterf/ClassInterf011/ClassInterf01101
vm/constantpool/ClassInterf/ClassInterf047/ClassInterf04701
vm/constantpool/ClassInterf/ClassInterf051/ClassInterf05101
vm/constantpool/ClassInterf/ClassInterf052/ClassInterf05201
Let's consider, for example, "ClassInterf00601".
The Java Virtual Machine, chapter 5 Constant Pool Resolution,
section 5.1.1 Current Class or Interface Not Loaded by a Class Loader, says:
" This phase of loading must detect the following errors:
...
- Otherwise, if it is determined that the selected file is not a
well-formed class file (pass 1 of 4.9.1), or is not a class file of a
supported major or minor version (4.1), class or interface resolution
throws a NoClassDefFoundError."
However, in the test below ClassFormatError is thrown instead of
NoClassDefFoundError.
See log and sources below.
----------------------------------------------------------------------------
> JH=/export/ld14/java/dest/jdk1.2H/solaris
> CLASSPATH="/export/ld32/sqe/harness_release/classes:."
> export CLASSPATH
> rm -rf *.class
> $JH/bin/java -fullversion
java full version "JDK1.2H"
> $JH/bin/javac -d . intrclss2.java ClassInterf00601.java
intrclss2.java:6: interface interf2 is defined in ClassInterf00601.java. Because it is used outside of its source file, it should be defined in a file called "interf2.java".
public class intrclss2 implements interf2{
^
1 warning
> $JH/bin/java javasoft.sqe.jcoder.Main -d . intrclss2.jcod
> $JH/bin/java -verify ClassInterf00601
Wrong exception thrown: java.lang.ClassFormatError: intrclss2 (Bad magic number)
> echo "status=" $?
status= 97
> JH=/export/ld14/java/dest/jdk1.1.4/solaris
> CLASSPATH="/export/ld32/sqe/harness_release/classes:."
> export CLASSPATH
> rm -rf *.class
> $JH/bin/java -fullversion
java full version "JDK1.1.4G"
> $JH/bin/javac -d . intrclss2.java ClassInterf00601.java
intrclss2.java:6: interface interf2 is defined in ClassInterf00601.java. Because it is used outside of its source file, it should be defined in a file called "interf2.java".
public class intrclss2 implements interf2{
^
1 warning
> $JH/bin/java javasoft.sqe.jcoder.Main -d . intrclss2.jcod
> $JH/bin/java -verify ClassInterf00601
> echo "status=" $?
status= 95
----------------------------------------------------------------------------
SOURCES:
::::::::::::::
ClassInterf00601.java
::::::::::::::
// Ident: @(#)ClassInterf00601.java 1.3 97/06/09
// Copyright 06/09/97 Sun Microsystems, Inc. All Rights Reserved
//package javasoft.sqe.tests.vm.constantpool.ClassInterf006.ClassInterf00601;
import java.io.PrintStream;
interface interf2 {
int mthd();
}
public class ClassInterf00601 {
public static int run(String argv[], PrintStream out) {
try {
interf2 i2 = new intrclss2();
i2.mthd();
System.out.println("No exception thrown?!");
} catch (NoClassDefFoundError e) {
return 0;
} catch (Throwable e) {
System.out.println("Wrong exception thrown: " + e);
return 2;
}
return 2;
}
public static void main(String argv[]) {
System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
}
}
::::::::::::::
intrclss2.java
::::::::::::::
// Ident: @(#)intrclss2.java 1.1 97/02/10
// Copyright 02/10/97 Sun Microsystems, Inc. All Rights Reserved
//package javasoft.sqe.tests.vm.constantpool.ClassInterf006.ClassInterf00601;
public class intrclss2 implements interf2{
public int mthd() {
return 2;
}
}
::::::::::::::
intrclss2.jcod
::::::::::::::
class intrclss2 {
0xCEFEBABE; // was: 0xCAFEBABE
3; // minor version
45; // version
[] { // Constant Pool
; // first element is empty
class #15; // #1
class #16; // #2
class #18; // #3
Method #3 #5; // #4
NameAndType #8 #7; // #5
Utf8 "()I"; // #6
Utf8 "()V"; // #7
Utf8 "<init>"; // #8
Utf8 "Code"; // #9
Utf8 "ConstantValue"; // #10
Utf8 "Exceptions"; // #11
Utf8 "LineNumberTable"; // #12
Utf8 "LocalVariables"; // #13
Utf8 "SourceFile"; // #14
Utf8 "interf2"; // #15
Utf8 "intrclss2"; // #16
Utf8 "intrclss2.java"; // #17
Utf8 "java/lang/Object"; // #18
Utf8 "mthd"; // #19
} // Constant Pool
0x0021; // access
#2;// this_cpx
#3;// super_cpx
[] { // Interfaces
#1;
} // Interfaces
[] { // fields
} // fields
[] { // methods
{ // Member
0x0001; // access
#19; // name_cpx
#6; // sig_cpx
[] { // Attributes
Attr(#9) { // Code
1; // max_stack
1; // max_locals
Bytes[] {
0x05AC;
};
[] { // Traps
} // end Traps
[] { // Attributes
Attr(#12) { // LineNumberTable
[] { // LineNumberTable
0 8;
}
} // end LineNumberTable
} // Attributes
} // end Code
} // Attributes
} // Member
;
{ // Member
0x0001; // access
#8; // name_cpx
#7; // sig_cpx
[] { // Attributes
Attr(#9) { // Code
1; // max_stack
1; // max_locals
Bytes[] {
0x2AB70004B1;
};
[] { // Traps
} // end Traps
[] { // Attributes
Attr(#12) { // LineNumberTable
[] { // LineNumberTable
0 6;
}
} // end LineNumberTable
} // Attributes
} // end Code
} // Attributes
} // Member
} // methods
[] { // Attributes
Attr(#14) { // SourceFile
#17;
} // end SourceFile
} // Attributes
} // end class intrclss2
======================================================================