harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Elena Sayapina (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-3895) [classlib][luni] Compatibility: Field.getXXX(null) exception throwing order differs on Harmony and RI
Date Thu, 17 May 2007 12:41:16 GMT
[classlib][luni] Compatibility: Field.getXXX(null) exception throwing order differs on Harmony
and RI
-----------------------------------------------------------------------------------------------------

                 Key: HARMONY-3895
                 URL: https://issues.apache.org/jira/browse/HARMONY-3895
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
            Reporter: Elena Sayapina
            Priority: Minor
         Attachments: getFieldTest.java

Methods Field.getXXX(Object obj) throw NullPointerException on Harmony if obj is null and
field is private, but throw IllegalAccessException on RI.

Please, consider the following code:

public class getFieldTest {

	static int i  = 0;
	static boolean bool  = false;
	static byte b  = 0;
	static short s  = 0;
	static long l  = 0l;
	static float f  = 0.0f;
	static double d  = 0.0d;
	static char c = '0';
	static Object o = null;
    
     public static void main(String[] args) {
         try {
             i = new SomeClass().getClass().getDeclaredField("i").getInt(null);
             System.out.println("TEST1 FAILED: no exceptions");
         } catch (IllegalAccessException iae) {
                  System.out.println("TEST1 PASSED: " + iae);
         } catch (Throwable t){
                  System.out.println("TEST1 FAILED: " + t);
         }
            
         try {
             bool = new SomeClass().getClass().getDeclaredField("bool").getBoolean(null);
             System.out.println("TEST2 FAILED: no exceptions");
         } catch (IllegalAccessException iae) {
                System.out.println("TEST2 PASSED: " + iae);
        } catch (Throwable t){
                System.out.println("TEST2 FAILED: " + t);
        }
         
        try {
            b =  new SomeClass().getClass().getDeclaredField("b").getByte(null);
            System.out.println("TEST3 FAILED: no exceptions");
        } catch (IllegalAccessException iae) {
            System.out.println("TEST3 PASSED: " + iae);
        } catch (Throwable t){
             System.out.println("TEST3 FAILED: " + t);
        }
        
        try {
            s =  new SomeClass().getClass().getDeclaredField("s").getShort(null);
            System.out.println("TEST4 FAILED: no exceptions");
        } catch (IllegalAccessException iae) {
            System.out.println("TEST4 PASSED: " + iae);
        } catch (Throwable t){
             System.out.println("TEST4 FAILED: " + t);
        }
        
        try {
            l =  new SomeClass().getClass().getDeclaredField("l").getLong(null);
            System.out.println("TEST5 FAILED: no exceptions");
        } catch (IllegalAccessException iae) {
            System.out.println("TEST5 PASSED: " + iae);
        } catch (Throwable t){
             System.out.println("TEST5 FAILED: " + t);
        }
        
        try {
            f =  new SomeClass().getClass().getDeclaredField("f").getFloat(null);
            System.out.println("TEST6 FAILED: no exceptions");
        } catch (IllegalAccessException iae) {
            System.out.println("TEST6 PASSED: " + iae);
        } catch (Throwable t){
             System.out.println("TEST6 FAILED: " + t);
        }
        
        try {
           d =  new SomeClass().getClass().getDeclaredField("d").getDouble(null);
            System.out.println("TEST7 FAILED: no exceptions");
        } catch (IllegalAccessException iae) {
            System.out.println("TEST7 PASSED: " + iae);
        } catch (Throwable t){
             System.out.println("TEST7 FAILED: " + t);
        }
        
        try {
           c =  new SomeClass().getClass().getDeclaredField("c").getChar(null);
            System.out.println("TEST8 FAILED: no exceptions");
        } catch (IllegalAccessException iae) {
            System.out.println("TEST8 PASSED: " + iae);
        } catch (Throwable t){
             System.out.println("TEST8 FAILED: " + t);
        }
        
        try {
           o = new SomeClass().getClass().getDeclaredField("o").get(null);
            System.out.println("TEST9 FAILED: no exceptions");
        } catch (IllegalAccessException iae) {
            System.out.println("TEST9 PASSED: " + iae);
        } catch (Throwable t){
            System.out.println("TEST9 FAILED: " + t);
        }
      }
}

class SomeClass {
    private int i  = 1;
    private boolean bool  = true;
    private byte b  = 1;
    private short s  = 1;
    private long l  = 1l;
    private float f  = 1.0f;
    private double d  = 1.0d;
    private char c = '1';
    private Object o = new Object();
}

Output on Harmony-r538805:

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 = r538805, (May 17 2007), Windows/ia32/msvc 1310, release build
http://incubator.apache.org/harmony

TEST1 FAILED: java.lang.NullPointerException: The specified object is null but the method
is not static
TEST2 FAILED: java.lang.NullPointerException: The specified object is null but the method
is not static
TEST3 FAILED: java.lang.NullPointerException: The specified object is null but the method
is not static
TEST4 FAILED: java.lang.NullPointerException: The specified object is null but the method
is not static
TEST5 FAILED: java.lang.NullPointerException: The specified object is null but the method
is not static
TEST6 FAILED: java.lang.NullPointerException: The specified object is null but the method
is not static
TEST7 FAILED: java.lang.NullPointerException: The specified object is null but the method
is not static
TEST8 FAILED: java.lang.NullPointerException: The specified object is null but the method
is not static
TEST9 FAILED: java.lang.NullPointerException: The specified object is null but the method
is not static

Output on HotSpot:

java version "1.5.0_11"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode)

TEST1 PASSED: java.lang.IllegalAccessException: Class getFieldTest can not access a member
of class SomeClass with modifiers "private"
TEST2 PASSED: java.lang.IllegalAccessException: Class getFieldTest can not access a member
of class SomeClass with modifiers "private"
TEST3 PASSED: java.lang.IllegalAccessException: Class getFieldTest can not access a member
of class SomeClass with modifiers "private"
TEST4 PASSED: java.lang.IllegalAccessException: Class getFieldTest can not access a member
of class SomeClass with modifiers "private"
TEST5 PASSED: java.lang.IllegalAccessException: Class getFieldTest can not access a member
of class SomeClass with modifiers "private"
TEST6 PASSED: java.lang.IllegalAccessException: Class getFieldTest can not access a member
of class SomeClass with modifiers "private"
TEST7 PASSED: java.lang.IllegalAccessException: Class getFieldTest can not access a member
of class SomeClass with modifiers "private"
TEST8 PASSED: java.lang.IllegalAccessException: Class getFieldTest can not access a member
of class SomeClass with modifiers "private"
TEST9 PASSED: java.lang.IllegalAccessException: Class getFieldTest can not access a member
of class SomeClass with modifiers "private"

Please, use attached getFieldTest.java for the test reproducing.


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


Mime
View raw message