Name: szC45993 Date: 03/21/97
The Java Virtual Machine, chapter 5 Constant Pool Resolution,
section 5.1.1 Current Class or Interface Not Loaded by Class Loader, claims:
"3. The class C is linked ($2.16.3), that is, it is verified ($4.9) and prepared.
...
If the class or interface C contained in class file C.class does not satisfy the static or structural constraints on valid class files listed in Section 4.8, "Constraints on Java Virtual Machine Code," class or interface resolution throws a VerifyError."
Chapter $4.8.1 says that "the last byte of the last instruction in the code array must be the byte at index code_length-1".
The violation of this constraint (see clss.jasm) does not lead to the
VerifyError throwing but leads to jvm crash for the JDK1.1.1C.
The undermentioned test gives the following result:
novo7% java -version
java version "JDK1.1.1C"
novo7% java -verify javasoft.sqe.tests.vm.constantpool.ClassInterf014.ClassInterf01401.ClassInterf01401
SIGSEGV 11* segmentation violation
si_signo [11]: SIGSEGV 11* segmentation violation
si_errno [0]: Error 0
si_code [1]: SEGV_ACCERR [addr: 0x0]
stackbase=EFFFFAB0, stackpointer=EFFFF7F0
Full thread dump:
"Finalizer thread" (TID:0xee3002b0, sys_thread_t:0xef310de0, state:R) prio=1
"Async Garbage Collector" (TID:0xee300268, sys_thread_t:0xef340de0, state:R) prio=1
"Idle thread" (TID:0xee300220, sys_thread_t:0xef370de0, state:R) prio=0
"Clock" (TID:0xee300110, sys_thread_t:0xef430de0, state:CW) prio=12
"main" (TID:0xee3000e0, sys_thread_t:0x46be0, state:R) prio=5 *current thread*
javasoft.sqe.tests.vm.constantpool.ClassInterf014.ClassInterf01401.Intrmdt.<clinit>(Intrmdt.jasm)
javasoft.sqe.tests.vm.constantpool.ClassInterf014.ClassInterf01401.ClassInterf01401.run(ClassInterf01401.java:21)
javasoft.sqe.tests.vm.constantpool.ClassInterf014.ClassInterf01401.ClassInterf01401.main(ClassInterf01401.java:45)
Monitor Cache Dump:
java.lang.Class@EE303AC8/EE34E120: owner "main" (0x46be0, 2 entries)
Registered Monitor Dump:
Thread queue lock: <unowned>
Verifier lock: <unowned>
Name and type hash table lock: <unowned>
String intern lock: <unowned>
JNI pinning lock: <unowned>
JNI global reference lock: <unowned>
BinClass lock: <unowned>
Class loading lock: owner "main" (0x46be0, 1 entry)
Java stack lock: <unowned>
Code rewrite lock: <unowned>
Heap lock: <unowned>
Has finalization queue lock: <unowned>
Finalize me queue lock: <unowned>
Monitor IO lock: <unowned>
Child death monitor: <unowned>
Event monitor: <unowned>
I/O monitor: <unowned>
Alarm monitor: <unowned>
Waiting to be notified:
"Clock"
Sbrk lock: <unowned>
Monitor cache expansion lock: <unowned>
Monitor registry: owner "main" (0x46be0, 1 entry)
Thread Alarm Q:
--------------------- ClassInterf01401.java
//File: @(#)ClassInterf01401.java 1.1 97/02/17
//Copyright 02/17/97 Sun Microsystems, Inc. All Rights Reserved
package javasoft.sqe.tests.vm.constantpool.ClassInterf014.ClassInterf01401;
import java.io.PrintStream;
import java.io.*;
import java.lang.*;
import java.util.*;
interface Inter {
int intrmdtprc(PrintStream out);
}
public class ClassInterf01401 {
public static int run(String argv[], PrintStream out) {
Inter i;
try{
i = (Inter) ((Class.forName("javasoft.sqe.tests.vm.constantpool.ClassInterf014.ClassInterf01401.Intrmdt")).newInstance());
} catch (java.lang.ClassNotFoundException e) {
out.println("CLASS NOT FOUND: " + e);
return 2;
}
catch (java.lang.IllegalAccessException e) {
out.println(e);
return 2;
}
catch (java.lang.InstantiationException e) {
out.println(e);
return 2;
};
return i.intrmdtprc(out);
}
public static void main(String argv[]) {
System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
}
}
--------------------- Intrmdt.jasm
package javasoft/sqe/tests/vm/constantpool/ClassInterf014/ClassInterf01401;
public class Intrmdt
implements Inter
{
// Compiled from Intrmdt.java
// Compiler version 3.45;
static Field c:"Ljavasoft/sqe/tests/vm/constantpool/ClassInterf014/ClassInterf01401/clss;";
public Method intrmdtprc:"(Ljava/io/PrintStream;)I"
stack 2 locals 2
{
try t8;
getstatic Field c:"Ljavasoft/sqe/tests/vm/constantpool/ClassInterf014/ClassInterf01401/clss;";
aload_1;
invokevirtual Method clss.prc:"(Ljava/io/PrintStream;)I";
ireturn;
endtry t8;
catch t8 java/lang/VerifyError;
//but NoClassDefFoundError is rised !?
pop;
iconst_0;
ireturn;
}
public Method <init>:"()V"
stack 1 locals 1
{
aload_0;
invokespecial Method java/lang/Object.<init>:"()V";
return;
}
static Method <clinit>:"()V"
stack 2 locals 0
{
new class clss;
dup;
invokespecial Method clss.<init>:"()V";
putstatic Field c:"Ljavasoft/sqe/tests/vm/constantpool/ClassInterf014/ClassInterf01401/clss;";
return;
}
} // end Class Intrmdt
--------------------- clss.jasm
class javasoft/sqe/tests/vm/constantpool/ClassInterf014/ClassInterf01401/clss {
0xCAFEBABE;
3; // minor version
45; // version
[18] { // Constant Pool
; // first element is empty
class #13; // #1 at 0x0A
class #15; // #2 at 0x0D
Method #1 #4; // #3 at 0x10
NameAndType #14 #17; // #4 at 0x15
Utf8 "(Ljava/io/PrintStream;)I"; // #5 at 0x1A
Utf8 "ConstantValue"; // #6 at 0x35
Utf8 "prc"; // #7 at 0x45
Utf8 "Exceptions"; // #8 at 0x4B
Utf8 "LineNumberTable"; // #9 at 0x58
Utf8 "SourceFile"; // #10 at 0x6A
Utf8 "LocalVariables"; // #11 at 0x77
Utf8 "Code"; // #12 at 0x88
Utf8 "java/lang/Object"; // #13 at 0x8F
Utf8 "<init>"; // #14 at 0xA2
Utf8 "javasoft/sqe/tests/vm/constantpool/ClassInterf014/ClassInterf01401/clss"; // #15 at 0xAB
Utf8 "clss.java"; // #16 at 0xF5
Utf8 "()V"; // #17 at 0x0101
} // Constant Pool
0x0001; // access
#2;// this_cpx
#1;// super_cpx
[0] { // Interfaces
} // Interfaces
[0] { // fields
} // fields
[2] { // methods
{ // Member at 0x0113
0x0001; // access
#7; // name_cpx
#5; // sig_cpx
[1] { // Attributes
Attr(#12, 26) { // Code at 0x011B
1; // max_stack
2; // max_locals
//////////////////////////////////////////////////////////////////////////////
//////////////////////////// jvm code constraints violation ($4.8.1,"The last byte of the last instruction in the code array must be the byte at index code_length-1"):
// Bytes[2] { //RIGHT VALUE.
Bytes[1] { //WRONG VALUE.
//////////////////////////////////////////////////////////////////////////////
0x05AC;
};
[0] { // Traps
} // end Traps
[1] { // Attributes
Attr(#9, 6) { // LineNumberTable at 0x012F
[1] { // LineNumberTable
0 13; // at 0x0137
}
} // end LineNumberTable
} // Attributes
} // end Code
} // Attributes
} // Member
;
{ // Member at 0x013B
0x0001; // access
#14; // name_cpx
#17; // sig_cpx
[1] { // Attributes
Attr(#12, 29) { // Code at 0x0143
1; // max_stack
1; // max_locals
Bytes[5] {
0x2AB70003B1;
};
[0] { // Traps
} // end Traps
[1] { // Attributes
Attr(#9, 6) { // LineNumberTable at 0x015A
[1] { // LineNumberTable
0 9; // at 0x0162
}
} // end LineNumberTable
} // Attributes
} // end Code
} // Attributes
} // Member
} // methods
[1] { // Attributes
Attr(#10, 2) { // SourceFile at 0x0168
#16;
} // end SourceFile
} // Attributes
} // end class javasoft/sqe/tests/vm/constantpool/ClassInterf014/ClassInterf01401/clss
---------------------
======================================================================