commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Emmanuel Bourg (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (BCEL-41) JustIce - array store type checks stricter than native verifier
Date Thu, 24 Apr 2014 13:58:15 GMT

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

Emmanuel Bourg updated BCEL-41:
-------------------------------

          Component/s:     (was: Main)
                       Verifier
          Description: 
Consider the class

{code}
public class Demo
{
    public static void main(String[] args)
    {
        Object[] objs = new Integer[1];
        objs[0] = o();
    }

    private static Object o()
    {
        return null;
    }
}
{code}

It compiles fine, and
{code}java -verify Demo{code}
executes without errors. However,
java org.apache.bcel.verifier.Verifier Demo
complains:

{code}
Pass 3b, method number 1 ['public static void main(String[] arg0)']:
VERIFIED_REJECTED
Constraint violated in method 'public static void main(String[] arg0)':
Instruction AASTORE constraint violated: The type of 'value' ('java.lang.Object') is not assignment

compatible to the components of the array 'arrayref' refers to. ('java.lang.Integer')
{code}

etc.

The problem is that while the vmspec2 says "The type of every value stored into an array of
type reference by an aastore instruction must be assignment compatible (§2.6.7) with the
component type of the array", the class file doesn't contain information on the compile-time
component type of the array. I suspect the native verifier does nothing about this requirement,
leaving the VM to throw an ArrayStoreException if problems arise.

Enver Haase asked me to mention in this report that while the error message says "assignment
compatible to" and the vmspec2 says "assignment compatible with", it's not a case of doing
the check the wrong way round.

  was:
Consider the class

public class Demo
{
    public static void main(String[] args)
    {
        Object[] objs = new Integer[1];
        objs[0] = o();
    }

    private static Object o()
    {
        return null;
    }
}

It compiles fine, and
java -verify Demo
executes without errors. However,
java org.apache.bcel.verifier.Verifier Demo
complains:

Pass 3b, method number 1 ['public static void main(String[] arg0)']:
VERIFIED_REJECTED
Constraint violated in method 'public static void main(String[] arg0)':
Instruction AASTORE constraint violated: The type of 'value' ('java.lang.Object') is not assignment

compatible to the components of the array 'arrayref' refers to. ('java.lang.Integer')
etc.

The problem is that while the vmspec2 says "The type of every value stored into an array of
type 
reference by an aastore instruction must be assignment compatible (§2.6.7) with the component

type of the array", the class file doesn't contain information on the compile-time component
type 
of the array. I suspect the native verifier does nothing about this requirement, leaving the
VM to 
throw an ArrayStoreException if problems arise.

Enver Haase asked me to mention in this report that while the error message says "assignment

compatible to" and the vmspec2 says "assignment compatible with", it's not a case of doing
the 
check the wrong way round.

             Priority: Major
          Environment:     (was: Operating System: All
Platform: All)
    Affects Version/s:     (was: unspecified)
             Priority:   (was: P3)
             Severity:   (was: normal)

> JustIce - array store type checks stricter than native verifier
> ---------------------------------------------------------------
>
>                 Key: BCEL-41
>                 URL: https://issues.apache.org/jira/browse/BCEL-41
>             Project: Commons BCEL
>          Issue Type: Bug
>          Components: Verifier
>            Reporter: Peter Taylor
>            Assignee: Apache Commons Developers
>
> Consider the class
> {code}
> public class Demo
> {
>     public static void main(String[] args)
>     {
>         Object[] objs = new Integer[1];
>         objs[0] = o();
>     }
>     private static Object o()
>     {
>         return null;
>     }
> }
> {code}
> It compiles fine, and
> {code}java -verify Demo{code}
> executes without errors. However,
> java org.apache.bcel.verifier.Verifier Demo
> complains:
> {code}
> Pass 3b, method number 1 ['public static void main(String[] arg0)']:
> VERIFIED_REJECTED
> Constraint violated in method 'public static void main(String[] arg0)':
> Instruction AASTORE constraint violated: The type of 'value' ('java.lang.Object') is
not assignment 
> compatible to the components of the array 'arrayref' refers to. ('java.lang.Integer')
> {code}
> etc.
> The problem is that while the vmspec2 says "The type of every value stored into an array
of type reference by an aastore instruction must be assignment compatible (§2.6.7) with the
component type of the array", the class file doesn't contain information on the compile-time
component type of the array. I suspect the native verifier does nothing about this requirement,
leaving the VM to throw an ArrayStoreException if problems arise.
> Enver Haase asked me to mention in this report that while the error message says "assignment
compatible to" and the vmspec2 says "assignment compatible with", it's not a case of doing
the check the wrong way round.



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

Mime
View raw message