You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Emmanuel Bourg (JIRA)" <ji...@apache.org> on 2014/04/24 12:07:22 UTC

[jira] [Comment Edited] (BCEL-4) Pass3b Verifier is corrupted

    [ https://issues.apache.org/jira/browse/BCEL-4?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13511614#comment-13511614 ] 

Emmanuel Bourg edited comment on BCEL-4 at 4/24/14 10:05 AM:
-------------------------------------------------------------

This is not a "simple" bug. Interfaces implemented directly are NOT forgotten.
{code}
import org.apache.bcel.*;
import org.apache.bcel.classfile.*;

public class Test {
    public static void main(String[] args) {
        JavaClass a = Repository.lookupClass("A");
        JavaClass c = Repository.lookupClass("B");
        System.out.println(a.implementationOf(c));
    }
}
{code}

This program prints "true"; and JavaClass.implementationOf() is what the static Repository methods are mapped to. The original test program lets the VERIFIER fail, it has a bug in its pass 3b implementation:

{code}
Pass 3b, method number 0 ['void <init>()']:VERIFIED_REJECTED
Constraint violated in method 'void <init>()':Instruction INVOKESPECIAL constraint violated: The 'objref' item '<UNINITIALIZED OBJECT OF TYPE 'A'>' does not implement 'java.lang.Object' as expected.InstructionHandle:
    1: invokespecial[183](3) 1
Execution Frame:
Local Variables:0: <UNINITIALIZED OBJECT OF TYPE 'A'>
OperandStack:
Slots used: 1
MaxStack: 1.<UNINITIALIZED OBJECT OF TYPE 'A'> (Size: 1)
Execution flow:
   0: aload_0   [InstructionContext]
   1: invokespecial 1   [InstructionContext]
{code}

Problem is that the JVM spec 4.9.4 mentions UNINITIALIZED objects as a special type, and this type indeed does not implement any interfaces.


was (Author: ehaase@inf.fu-berlin.de):
This is not a "simple" bug. Interfaces implemented directly are NOTforgotten.---------import org.apache.bcel.*;import org.apache.bcel.classfile.*; public class Test{public static void main(String[] args){     JavaClass a = Repository.lookupClass("A");    JavaClass c = Repository.lookupClass("B");    System.out.println(a.implementationOf(c));}}-------This program prints "true"; and JavaClass.implementationOf()is what the static Repository methods are mapped to.The original test program lets the VERIFIER fail, it hasa bug in its pass 3b implementation:----------------Pass 3b, method number 0 ['void <init>()']:VERIFIED_REJECTEDConstraint violated in method 'void <init>()':Instruction INVOKESPECIAL constraint violated: The 'objref' item '<UNINITIALIZED OBJECT OF TYPE 'A'>' does not implement 'java.lang.Object' as expected.InstructionHandle:    1: invokespecial[183](3) 1 Execution Frame:Local Variables:0: <UNINITIALIZED OBJECT OF TYPE 'A'>OperandStack:Slots used: 1 MaxStack: 1.<UNINITIALIZED OBJECT OF TYPE 'A'> (Size: 1)Execution flow:   0: aload_0   [InstructionContext]   1: invokespecial 1   [InstructionContext]-----------------Problem is that the JVM spec 4.9.4 mentions UNINITIALIZEDobjects as a special type, and this type indeed does notimplement any interfaces.

> Pass3b Verifier is corrupted
> ----------------------------
>
>                 Key: BCEL-4
>                 URL: https://issues.apache.org/jira/browse/BCEL-4
>             Project: Commons BCEL
>          Issue Type: Bug
>          Components: Main
>    Affects Versions: 5.0
>         Environment: Operating System: All
> Platform: All
>            Reporter: Peter Schneider
>            Assignee: Apache Commons Developers
>
> The Repostiroty method
> public static boolean implementationOf(JavaClass clazz, JavaClass inter);
> Isn't working correctly. Therefore the Cast checks performed in the Pass3b 
> verifier are wrong.
> With this simple program the verifcation fails.
> (tested with jdk1.4.0 W32)
> <code>
> class A implements B{
> 	static C temp;
> 	public static void main(String[] args){
> 		temp = new A();
> 	}
> }
> interface B extends C{
> }
> interface C{
> }
> </code>
> The reason is simple. Interfaces are checked only directly. Interfaces 
> inherited indirectly are forgotten.
> There is another version of this bug, where even direct implemented interfaces 
> are not recognized, but i wasn't able to reduce it to a simple example.



--
This message was sent by Atlassian JIRA
(v6.2#6252)