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/05/21 18:16:16 UTC

[jira] Assigned: (HARMONY-3832) [drlvm][classloader] VM does not throw ClassFormatError when class_info contains wrong name_index

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

Gregory Shimansky reassigned HARMONY-3832:
------------------------------------------

    Assignee: Gregory Shimansky

> [drlvm][classloader]  VM does not throw ClassFormatError when class_info contains wrong name_index
> --------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-3832
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3832
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>         Environment: Windows and Linux
>            Reporter: Vera Petrashkova
>         Assigned To: Gregory Shimansky
>            Priority: Minor
>         Attachments: aaa.zip, add_check_of_super_class_name.patch
>
>
> According J2SE VM specification
>     If the purported representation is not in class file format, loading throws an instance of ClassFormatError.
> If class file contains class_info with wrong name_index  which refers to the wrong element, for example "[Zaaa"
> then VM throws ClassFormatError only in case of  it starts with  -Xverify option.
> Otherwise VM throws NoClassDefFoundError.
> But RI throws ClassFormatError in both cases with and without -Xverify option.
> To reproduce this issue run the following synthetic test:
> ------------test111.java--------------
> import java.io.*;
> public class test111 {
>    public static void main (String[] args) {  
>         try {        
>             Class cl = Class.forName("aaa");
>             cl.newInstance();
>             System.out.println("Test failed");
>         } catch (ClassFormatError e) {
>             System.out.println("Test passed");
>             System.out.println(e);
>         } catch (Throwable e) {            
>             System.out.println("Test failed: unexpected error");
>             e.printStackTrace();
>         }
>     }
> }
> ------------------aaa.ccode---------------
> magic = xCAFEBABE
> minor_version = 0
> major_version = 49
> constant_pool_count = 5
> constant_pool {
>   /* #1 */ Class = #3
> //////////////////////////////////////////////////
>   /* #2 */ UTF8 = "[Zaaa" // wrong format
> //////////////////////////////////////////////////
>   /* #3 */ UTF8 = "aaa"
>   /* #4 */ Class = #2
> }
> access_flags = PUBLIC SUPER  // x21
> this_class = #1
> super_class = #4  // "[Zaaa"
> interfaces_count = 0
> fields_count = 0
> methods_count = 0
> attributes_count = 0
> -------------------------------------
> aaa class file can be created using VMTT tool from http://issues.apache.org/jira/browse/HARMONY-3206
> Attachment contains created  aaa class file.
> Run test111
> java -cp . -Xverify test111
> java -cp . test111
> DRLVM output:
> ===============
> 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 = r536537, (May  9 2007), Windows/ia32/msvc 1310, debug build
> http://incubator.apache.org/harmony
> Test passed
> java.lang.ClassFormatError: aaa: illegal CONSTANT_Class name "[Zaaa"
> 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 = r536537, (May  9 2007), Windows/ia32/msvc 1310, debug build
> http://incubator.apache.org/harmony
> Test failed: unexpected error
> java.lang.NoClassDefFoundError: [Zaaa
>         at java.lang.ClassLoader.defineClass0(ClassLoader.java)
>         at java.lang.ClassLoader.defineClass(ClassLoader.java:417)
>         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:70)
>         at java.net.URLClassLoader.findClassImpl(URLClassLoader.java:1214)
>         at java.net.URLClassLoader$4.run(URLClassLoader.java:625)
>         at java.net.URLClassLoader$4.run(URLClassLoader.java:1)
>         at java.security.AccessController.doPrivilegedImpl(AccessController.java:171)
>         at java.security.AccessController.doPrivileged(AccessController.java:64)
>         at java.net.URLClassLoader.findClass(URLClassLoader.java:627)
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:554)
>         at java.lang.ClassLoader$SystemClassLoader.loadClass(ClassLoader.java:942)
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:311)
>         at java.lang.Class.forName(Class.java:170)
>         at java.lang.Class.forName(Class.java:127)
>         at test111.main(test111.java:7)
> RI output:
> ============
> 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)
> Test passed
> java.lang.ClassFormatError: Illegal class name "[Zaaa" in class file aaa
> 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)
> Test passed
> java.lang.ClassFormatError: Bad superclass name in class file aaa
> This issue caused the failures of the following tests from Stress test suite http://issues.apache.org/jira/browse/HARMONY-3536
> stress/org/apache/harmony/test/stress/classloader/MixThreads/LargeClassName/testLargeClassName_W1
> stress/org/apache/harmony/test/stress/classloader/MixThreads/LargeClassName/testLargeClassName_W2
> stress/org/apache/harmony/test/stress/classloader/NotSynchThreads/LargeClassName/testLargeClassName_W1
> stress/org/apache/harmony/test/stress/classloader/NotSynchThreads/LargeClassName/testLargeClassName_W2
> stress/org/apache/harmony/test/stress/classloader/OneThread/LargeClassName/testLargeClassName_W2
> stress/org/apache/harmony/test/stress/classloader/SynchThreads/LargeClassName/testLargeClassName_W1
> stress/org/apache/harmony/test/stress/classloader/SynchThreads/LargeClassName/testLargeClassName_W2

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