commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jérôme Leroux (JIRA) <j...@apache.org>
Subject [jira] [Commented] (BCEL-191) Verifier assumes the classes of the verifier are in the classpath of the verified class
Date Tue, 13 Jan 2015 09:03:34 GMT

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

Jérôme Leroux commented on BCEL-191:
------------------------------------

Currently, the GenericArray is used when the verifier detects that the receiver of a method
invokation is an array. In this case, the type of the receiver (ArrayType) is replaced by
the type ObjectType that references the class GenericArray. To verify that the receiver of
the called method is compatible with the method, the verifier uses the method Repository.instanceOf(String,
String). In our case, the instanceOf method checks that GenericArray is compatible with the
type that defines the method (Object in my example).

Instead of mocking an ArrayType with an ObjectType, I kept the ArrayType and use the method
ReferenceType.isCastableTo(Type). This method already manages the ArrayType so there is no
need to mock it with GenericArray class.

> Verifier assumes the classes of the verifier are in the classpath of the verified class
> ---------------------------------------------------------------------------------------
>
>                 Key: BCEL-191
>                 URL: https://issues.apache.org/jira/browse/BCEL-191
>             Project: Commons BCEL
>          Issue Type: Bug
>          Components: Verifier
>            Reporter: Jérôme Leroux
>            Priority: Minor
>         Attachments: BCEL-191.patch
>
>
> When verifying a class, the verifier looks for this class and its dependencies in a classpath
configured for this verification. If the classes of the verifier itself are not in this classpath,
then an error can occur.
> The causes is the use of the internal class {{org.apache.bcel.verifier.structurals.GenericArray}}
to mock the array class when a method invokation is done on an array. If the class {{GenericArray}}
is not available in the classpath of the verifier class, we get the following error:
> {quote}
> Exception in thread "main" org.apache.bcel.verifier.exc.AssertionViolatedException: INTERNAL
ERROR: Some RuntimeException occured while verify()ing class 'org.apache.bcel.verifier.tests.TestArray01',
method 'public static void test1()'. Original RuntimeException's stack trace:
> ---
> org.apache.bcel.verifier.exc.AssertionViolatedException: INTERNAL ERROR: Missing class:
java.lang.ClassNotFoundException: Exception while looking for class org.apache.bcel.verifier.structurals.GenericArray:
java.io.IOException: Couldn't find: org/apache/bcel/verifier/structurals/GenericArray.class
> 	at org.apache.bcel.verifier.structurals.InstConstraintVisitor.visitINVOKEVIRTUAL(InstConstraintVisitor.java:2059)
> 	…
> {quote}
> Here is a simple example of code that raises this exception:
> {code:java}
>     public static void test1(){
>         String[] a = new String[4];
>         a.equals(null);
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message