You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Gregory Shimansky (JIRA)" <ji...@apache.org> on 2007/03/16 13:47:09 UTC

[jira] Assigned: (HARMONY-3316) [drlvm]VM throws VerifyError instead of ClassFormatError when class contains incorrect method name

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

Gregory Shimansky reassigned HARMONY-3316:
------------------------------------------

    Assignee: Gregory Shimansky

> [drlvm]VM throws VerifyError instead of ClassFormatError when class contains incorrect method name
> --------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-3316
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3316
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>         Environment: Windows and Linux
>            Reporter: Vera Petrashkova
>         Assigned To: Gregory Shimansky
>            Priority: Minor
>         Attachments: 3316.patch, WrongMethName.zip
>
>
> If class file contains CONSTANT_NameAndType element which refers to incorrect method name then
> VM throws expected ClassFormatError when -Xverify option was specified.
> If this option was not set VM throws VerifyError while RI always throws ClassFormatError.
> The following synthetic test demonstrates this issue:
> --------------testWrongMethName.java---------------
> import java.io.*;
> public class testWrongMethName {
>     public static void main (String[] args) {
>         try {
>             Class.forName("WrongMethName");
>         } catch (ClassFormatError e) {
>             System.out.println("Test passed: " + e);
>         } catch (Throwable e) {
>             System.out.println("Test failed: unexpected error" + e);
>             e.printStackTrace(System.out);
>         }
>     }
> }
> -------------WrongMethName.ccode------------------------
> magic = xCAFEBABE
> minor_version = 3
> major_version = 45
> constant_pool_count = 13
> constant_pool {
>   /* #1 */ UTF8 = "WrongMethName"
>   /* #2 */ UTF8 = "java/lang/Object"
>   /* #3 */ Class = #2
>   /* #4 */ Class = #1
>   /* #5 */ UTF8 = "<init>"
>   /* #6 */ UTF8 = "()V"
>   /* #7 */ UTF8 = "Code"
>   /* #8 */ Method = #3 #9
>   /* #9 */ NameAndType = #12 #6    // incorrect #12
>   /* #10 */ UTF8 = "I"
>   /* #11 */ UTF8 = "testF"
>   /* #12 */ UTF8 = "<testF>"
> }
> access_flags = PUBLIC SUPER
> this_class = #4
> super_class = #3
> interfaces_count = 0
> fields_count = 1
> fields {
>     field {
>         access_flag = PUBLIC
>         name_index = #11
>         descriptor_index = #10
>         attributes_count = 0
>     }
> }
> methods_count = 1
> methods {
>     method {
>         access_flag = PUBLIC
>         name_index = #5
>         descriptor_index = #6
>         attributes_count = 1
>         attributes {
>             attribute Code {
>             attribute_name_index = #7
>             attribute_length = 17
>             max_stack = 1
>             max_locals = 1
>             code_length = 5
>             code asm {
>                 0:    aload_0
>                 1:    invokespecial #8
>                 4:    return
>             }
>             exception_table_length = 0
>             attributes_count = 0
>             }
>         }
>     }
> }
> attributes_count = 0
> --------------------------------------
> To run this test use WrongMethName class from attachment
> Output is:
> Test failed: unexpected errorjava.lang.VerifyError: (class: WrongMethName, method: <init>()V) Uninitialized reference usage
> java.lang.VerifyError: (class: WrongMethName, method: <init>()V) Uninitialized reference usage
>         at java.lang.ClassLoader.defineClass0(ClassLoader.java)
>         at java.lang.ClassLoader.defineClass(ClassLoader.java:414)
>         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:70)
>         at java.net.URLClassLoader.findClassImpl(URLClassLoader.java:1182)
>         at java.net.URLClassLoader$4.run(URLClassLoader.java:624)
>         at java.net.URLClassLoader$4.run(URLClassLoader.java)
>         at java.security.AccessController.doPrivilegedImpl(AccessController.java:171)
>         at java.security.AccessController.doPrivileged(AccessController.java:62)
>         at java.net.URLClassLoader.findClass(URLClassLoader.java:622)
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:552)
>         at java.lang.ClassLoader$SystemClassLoader.loadClass(ClassLoader.java:938)
>         at java.lang.ClassLoader.loadClass(ClassLoader.java)
>         at java.lang.Class.forName(Class.java:153)
>         at java.lang.Class.forName(Class.java:128)
>         at testWrongMethName.main(testWrongMethName.java:5)
> VM throws VerifyError when Class.forName() is invoked with incorrect class file.
> But it always throws ClassFormatError when we use ClassLoader.defineClass(..) with this wrong class.

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