-
Bug
-
Resolution: Fixed
-
P2
-
1.4.0
-
beta
-
generic, x86, sparc
-
generic, linux, solaris_2.6, solaris_7, solaris_8, windows_95, windows_2000
-
Verified
Name: vrR10176 Date: 03/22/2001
Api spec says about method invoke (java.lang.reflect.Method):
"public Object invoke(Object obj, Object[] args)
throws IllegalAccessException,
IllegalArgumentException,
InvocationTargetException
... skip ...
Control transfers to the invoked method. If the method completes
abruptly by throwing an exception, the exception is placed in an
InvocationTargetException and thrown in turn to the caller of invoke.
... skip ...
Throws:
InvocationTargetException - if the underlying method throws an exception.
... skip ..."
And JVMS-2 says (chapter 2.16, Exceptions, p.40):
"Every exception is represented by an instance of the class Throwable
or one of its subclasses"
Therefore, if the method completes abruptly by throwing LinkageError
(for example NoSuchFieldError), this error should be placed in an
InvocationTargetException and thrown in turn to the caller of invoke,
as this error is exception and subclass of Throwable. But JVM
(jdk1.4.0beta-b54,b55,b56) does not place LinkageError to
InvocationTargetException and throws it immediately. This is jdk
regression, all previous jdk throws InvocationTargetException
instead of LinkageError.
The bug affects a lot of jck vm tests.
To reproduce the issue execute following test.
Compile first test.java and then test2.java
------------ test.java ------------------------
package invoke_test;
import java.lang.reflect.*;
abstract class testA{
static int f;
}
class test1 extends testA{
static void run(){
f = 2;
}
}
public class test {
public static void main(String args[]) {
try {
Class test_class = Class.forName("invoke_test.test1");
Method runMethod = test_class.getDeclaredMethod("run", new Class[]{});
Object ignore = runMethod.invoke(null, new Object[]{});
} catch (InvocationTargetException e) {
Throwable ee = e.getTargetException();
System.out.println("Exception " + e + " wraps: " + ee);
System.out.println("Test passed");
} catch (Throwable e) {
System.out.println("Failed with unexpected exception: " + e);
}
}
}
------------ test2.java ------------------------
package invoke_test;
abstract class testA{
}
------------ Logs -----------------------------
$ javac -d . test.java
$ javac -d . test2.java
$ java -version
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b56)
Java HotSpot(TM) Client VM (build 1.4-beta-B56, mixed mode)
$ java -Xfuture invoke_test.test
Failed with unexpected exception: java.lang.NoSuchFieldError: f
------------ Logs , some previous jdks----------
----jdk1.4.0beta-b53----
$ java -version
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b53)
Java HotSpot(TM) Client VM (build 1.4beta-B53, mixed mode)
$ java -Xfuture invoke_test.test
Exception java.lang.reflect.InvocationTargetException wraps: java.lang.NoSuchFieldError: f
Test passed
----jdk1.3.0fcsC----
$ java -version
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, interpreted mode)
$java -Xfuture invoke_test.test
Exception java.lang.reflect.InvocationTargetException wraps: java.lang.NoSuchFieldError: f
Test passed
----jdk1.2fcsV----
$ java -version
java version "1.2"
Classic VM (build JDK-1.2-V, green threads, sunwjit)
$ java -Xfuture invoke_test.test
Exception java.lang.reflect.InvocationTargetException wraps: java.lang.NoSuchFieldError: invoke_test.testA: field f not found
Test passed
-----------------------------------------------
======================================================================
Name: dkR10014 Date: 04/03/2001
This bug affects the following test from testbase_nsk:
nsk/stress/except/except001
======================================================================
- duplicates
-
JDK-4422587 JCK13a: Three vm/instr/new tests fail with java.lang.InstantiationError
- Closed
-
JDK-4422591 JCK13a: Some vm tests fail with java.lang.IncompatibleClassChangeError
- Closed
-
JDK-4423702 JCK13a: Four vm/instr tests fail with java.lang.NoSuchFieldError
- Closed
-
JDK-4423710 JCK13a: vm test invokevirtual01803m1 fails with java.lang.AbstractMethodError
- Closed
-
JDK-4423711 JCK13a: Some vm tests fail with java.lang.IllegalAccessError
- Closed
-
JDK-4423721 JCK13a: Two vm/instr tests fail with java.lang.NoClassDefFoundError
- Closed
-
JDK-4423616 JCK13a vm/jni/Miscellaneous/misc001/misc00101/misc00101.html
- Closed
- relates to
-
JDK-4430805 Class.newInstance() needs more precise specification
- Closed
-
JDK-4451928 HS1.4(sparc): 32-bit server crashed by nsk/stress/except/except001
- Closed
-
JDK-6531596 Wrong exception from Method.invoke() call
- Closed