-
Bug
-
Resolution: Not an Issue
-
P3
-
7, 8, 9
-
generic
-
generic
FULL PRODUCT VERSION :
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) Server VM (
FULL OS VERSION :
Darwin mac-esxi-38 12.5.0 Darwin Kernel Version 12.5.0: Sun Sep 29 13:33:47 PDT 2013; root:xnu-2050.48.12~1/RELEASE_X86_64 x86_64
Linux intellij-linux-app39-70 3.19.0-69-generic #77~14.04.1-Ubuntu SMP
A DESCRIPTION OF THE PROBLEM :
According the JVM specification (4.6): "If a method of a class or interface has its ACC_ABSTRACT flag set, it must not have any of its ACC_PRIVATE, ACC_STATIC, ACC_FINAL, ACC_SYNCHRONIZED, ACC_NATIVE, or ACC_STRICT flags set."
However, JVM loads interfaces declaring abstract+synchronized method (and classes implementing these interfaces) without any errors.
It can be observed on the example below.
This example provides the interface testMethodsIntfFlags_4I.j with abstract+synchronized method, the class testMethodsIntfFlags_4C.j implementing this interface and the class Test.java which tries to instantiate testMethodsIntfFlags_4C. The interface and the class were written in Jasmin (see http://jasmin.sourceforge.net)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) compile testMethodsIntfFlags_4I.j and testMethodsIntfFlags_4C.j using jasmin
2) compile and run Test.java
EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected: testMethodsIntfFlags_4C won't be instantiated and ClassFormatError (or VerifyError) will be thrown
Actual: testMethodsIntfFlags_4C is loaded without any errors
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
testMethodsIntfFlags_4I.j
.interface testMethodsIntfFlags_4I
.super java/lang/Object
.method public abstract synchronized test(I)I
.end method
--------------------8<--------------------
testMethodsIntfFlags_4C.j
.class public testMethodsIntfFlags_4C
.super java/lang/Object
.implements testMethodsIntfFlags_4I
;
; standard initializer
.method public <init>()V
aload_0
invokenonvirtual java/lang/Object/<init>()V
return
.end method
; test
.method public test(I)I
.limit stack 2
.limit locals 2
iload_1
ireturn
.end method
--------------------8<--------------------
Test.java
public class Test {
public static void main(String[] args) {
System.out.println("Verify: public abstract synchronized interface method");
try {
Class cl = Class.forName("testMethodsIntfFlags_4C");
cl.newInstance();
return failed("class loaded and instantiated");
} catch (ClassFormatError e) {
System.out.println("caught ClassFormatError (expected)");
} catch (Throwable e) {
System.out.println("caught " + e);
}
}
}
---------- END SOURCE ----------
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) Server VM (
FULL OS VERSION :
Darwin mac-esxi-38 12.5.0 Darwin Kernel Version 12.5.0: Sun Sep 29 13:33:47 PDT 2013; root:xnu-2050.48.12~1/RELEASE_X86_64 x86_64
Linux intellij-linux-app39-70 3.19.0-69-generic #77~14.04.1-Ubuntu SMP
A DESCRIPTION OF THE PROBLEM :
According the JVM specification (4.6): "If a method of a class or interface has its ACC_ABSTRACT flag set, it must not have any of its ACC_PRIVATE, ACC_STATIC, ACC_FINAL, ACC_SYNCHRONIZED, ACC_NATIVE, or ACC_STRICT flags set."
However, JVM loads interfaces declaring abstract+synchronized method (and classes implementing these interfaces) without any errors.
It can be observed on the example below.
This example provides the interface testMethodsIntfFlags_4I.j with abstract+synchronized method, the class testMethodsIntfFlags_4C.j implementing this interface and the class Test.java which tries to instantiate testMethodsIntfFlags_4C. The interface and the class were written in Jasmin (see http://jasmin.sourceforge.net)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) compile testMethodsIntfFlags_4I.j and testMethodsIntfFlags_4C.j using jasmin
2) compile and run Test.java
EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected: testMethodsIntfFlags_4C won't be instantiated and ClassFormatError (or VerifyError) will be thrown
Actual: testMethodsIntfFlags_4C is loaded without any errors
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
testMethodsIntfFlags_4I.j
.interface testMethodsIntfFlags_4I
.super java/lang/Object
.method public abstract synchronized test(I)I
.end method
--------------------8<--------------------
testMethodsIntfFlags_4C.j
.class public testMethodsIntfFlags_4C
.super java/lang/Object
.implements testMethodsIntfFlags_4I
;
; standard initializer
.method public <init>()V
aload_0
invokenonvirtual java/lang/Object/<init>()V
return
.end method
; test
.method public test(I)I
.limit stack 2
.limit locals 2
iload_1
ireturn
.end method
--------------------8<--------------------
Test.java
public class Test {
public static void main(String[] args) {
System.out.println("Verify: public abstract synchronized interface method");
try {
Class cl = Class.forName("testMethodsIntfFlags_4C");
cl.newInstance();
return failed("class loaded and instantiated");
} catch (ClassFormatError e) {
System.out.println("caught ClassFormatError (expected)");
} catch (Throwable e) {
System.out.println("caught " + e);
}
}
}
---------- END SOURCE ----------