You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Mikhail Loenko (JIRA)" <ji...@apache.org> on 2007/07/18 10:29:05 UTC

[jira] Resolved: (HARMONY-4409) [drlvm][verifier] Harmony throws VerifyError (Incompatible argument for function) on generics/varargs specific bytecode while RI doesn't

     [ https://issues.apache.org/jira/browse/HARMONY-4409?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mikhail Loenko resolved HARMONY-4409.
-------------------------------------

    Resolution: Fixed

the issue was resolved with switching to HARMONY-3363 verifier

> [drlvm][verifier] Harmony throws VerifyError (Incompatible argument for function) on generics/varargs specific bytecode while RI doesn't
> ----------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4409
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4409
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Nina Rinskaya
>            Assignee: Mikhail Loenko
>            Priority: Minor
>
> Harmony throws VerifyError (Incompatible argument for function) on generics/varargs specific bytecode while RI doesn't. 
> This issue affects 1 EUT 3.2/3.3 testcase: org.eclipse.jdt.core.tests.compiler.regression.VarargsTest.test030 - 1.5
> To reproduce:
> Compile the testcase below using Sun javac or BEA javac or Eclipse 3.3 compiler:
> ---- X.java ----
> public class X {
>     public static void main(String[] args) {
>         test("X", new Integer(1));
>         System.out.println("PASSED");
>     }
>     public static <A extends Comparable> void test(A... args) {
>     }
> }
> ---- End of X.java ----
> If you compile this code with Sun javac 1.5 (same with BEA 1.5/ Eclipse compiler 3.3), you'll get the following bytecode:
> $javap -c X
> Compiled from "X.java"
> public class X extends java.lang.Object{
> public X();
>   Code:
>    0:   aload_0
>    1:   invokespecial   #1; //Method java/lang/Object."<init>":()V
>    4:   return
> public static void main(java.lang.String[]);
>   Code:
>    0:   iconst_2
>    1:   anewarray       #2; //class java/io/Serializable
>    4:   dup
>    5:   iconst_0
>    6:   ldc     #3; //String X
>    8:   aastore
>    9:   dup
>    10:  iconst_1
>    11:  new     #4; //class java/lang/Integer
>    14:  dup
>    15:  iconst_1
>    16:  invokespecial   #5; //Method java/lang/Integer."<init>":(I)V
>    19:  aastore
>    20:  invokestatic    #6; //Method test:([Ljava/lang/Comparable;)V
>    23:  getstatic       #7; //Field java/lang/System.out:Ljava/io/PrintStream;
>    26:  ldc     #8; //String PASSED
>    28:  invokevirtual   #9; //Method java/io/PrintStream.println:(Ljava/lang/String;)V
>    31:  return
> public static void test(java.lang.Comparable[]);
>   Code:
>    0:   return
> }
> ----------------------------------
> Output on RI (Sun 1.5 and BEA 1.5, Sun 1.5 with -Xfuture option):
> java version "1.5.0_06"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
> Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode)
> PASSED
> Output on Harmony:
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r551077, (Jun 27 2007), Windows/ia32/msvc 1310, release build
> http://harmony.apache.org
> Uncaught exception in main:
> java.lang.VerifyError: (class: X, method: main([Ljava/lang/String;)V) Incompatible argument for function
> FAILED to invoke JVM.
> Ouput on Harmony with -noverify:
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r551077, (Jun 27 2007), Windows/ia32/msvc 1310, release build
> http://harmony.apache.org
> PASSED
> ----------------------------------
> It looks that Harmony reports java.lang.VerifyError: (class: X, method: main([Ljava/lang/String;)V) Incompatible argument for function because of
>   1:   anewarray       #2; //class java/io/Serializable
> and
>    20:  invokestatic    #6; //Method test:([Ljava/lang/Comparable;)V
> For some reasons if all actual varargs method arguments implement specific interfaces (I reproduced it for java.io.Serializable, java.lang.Comparable, but it's not reproducible with custom interfaces and some other J2SE API interfaces. If both Comparable and Serializable are implemented, Serilalizable would be selected as array type) javac creates an array of this interface type for varargs arguments. RI verifier accepts such array as vararg method argument, but HY doesn't. It's not reproducible with non-generic types. 
> BCEL 5.2 tool (http://jakarta.apache.org/bcel) also reports verification issue:
> java -cp C:\work\harmony-hdk-551077\jdk\jre\lib\boot\bcel-5.2\bcel-5.2.jar;. org.apache.bcel.verifier.Verifier X.class
> ...
> Pass 3b, method number 1 ['public static void main(String[] arg0)']:
> VERIFIED_REJECTED
> Constraint violated in method 'public static void main(String[] arg0)':
> Instruction INVOKESTATIC constraint violated: Expecting a 'java.lang.Comparable[]' but found a 'java.io.Serializable[]' on the stack (
> which is not assignment compatible). 
> InstructionHandle:   20: invokestatic[184](3) 6
> ...
> Unfortunately I can't find the expected behavior description in VM spec to prove which behavior is correct (invokestatic description says "The operand stack must contain nargs argument values, where the number, type, and order of the values must be consistent with the descriptor of the resolved method" where it's not clear what "consistent" means)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.