You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Vera Petrashkova (JIRA)" <ji...@apache.org> on 2007/03/07 06:50:24 UTC

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

[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
            Priority: Minor


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.


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

Posted by "Vera Volynets (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3316?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Vera Volynets updated HARMONY-3316:
-----------------------------------

    Attachment: 3316.patch

The patch fixes the problem. I made special check for method names which start with "<". 
This check doesn't depend on flag -Xverify. 

> [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
>            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.


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

Posted by "Vera Volynets (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3316?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12481126 ] 

Vera Volynets commented on HARMONY-3316:
----------------------------------------

VM behaves like BEA, but not as RI.
It seems that RI checks method name 2 times and 2 times runs through constant pool.
I suppose that first time it runs through constant pool just after parsing and second time before verifying.
The first check is obligatory and the second only if -Xverify is on. It looks like code is duplicated.
Now our vm makes check after parsing and only if -Xverify is on. 

I suppose to leave it as it is or make method name check independently of -Xverify flag.

> [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
>            Priority: Minor
>         Attachments: 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.


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

Posted by "Vera Petrashkova (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3316?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12482309 ] 

Vera Petrashkova commented on HARMONY-3316:
-------------------------------------------

Now VM throws ClassFormatError as expected.


> [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.


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

Posted by "Gregory Shimansky (JIRA)" <ji...@apache.org>.
     [ 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.


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

Posted by "Gregory Shimansky (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3316?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gregory Shimansky closed HARMONY-3316.
--------------------------------------


VERIFIED

> [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.


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

Posted by "Vera Petrashkova (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3316?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Vera Petrashkova updated HARMONY-3316:
--------------------------------------

    Attachment: WrongMethName.zip

WrongMethName.zip file contains test source code and class files.

> [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
>            Priority: Minor
>         Attachments: 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.


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

Posted by "Gregory Shimansky (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3316?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gregory Shimansky resolved HARMONY-3316.
----------------------------------------

    Resolution: Fixed

Patch applied at 520001. Please check that it was applied as expected and the bug is gone now.

> [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.