United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-5003431 : java.lang.Object cannot be dereferenced

Details
Type:
Bug
Submit Date:
2004-02-25
Status:
Closed
Updated Date:
2007-12-07
Project Name:
JDK
Resolved Date:
2006-01-07
Component:
tools
OS:
solaris_8
Sub-Component:
javac
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
5.0
Fixed Versions:

Related Reports
Duplicate:
Duplicate:
Relates:

Sub Tasks

Description
See <http://forum.java.sun.com/thread.jsp?forum=316&thread=495830>

class Test {
    static class SomeType<T> { T t = null; }

    static <T> T nil() { return (new SomeType<T>()).t; }

    public static void test() {
        nil().getClass();               // error: java.lang.Object cannot be dereferenced
    }
}

                                    

Comments
EVALUATION

A bug.

###@###.### 2004-02-25
                                     
2004-02-25
PUBLIC COMMENTS

...
                                     
2004-09-07
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
dragon


                                     
2004-09-07
SUGGESTED FIX

Index: src/share/classes/com/sun/tools/javac/comp/Infer.java
============================================================
@@ -247,7 +251,7 @@
 	List<Type> targs = Type.map(undetvars, getInstFun);
 	checkWithinBounds(that.tvars, targs, warn);
 
-	return qtype1.map(getInstFun);
+	return getInstFun.apply(qtype1);
     }
 
     /** Instantiate method type `mt' by finding instantiations of

###@###.### 2005-2-01 08:14:58 GMT
                                     
2005-02-01
WORK AROUND

Test.<Object>nil().getClass();

###@###.### 2005-03-26 02:56:24 GMT
                                     
2005-03-26
SUGGESTED FIX

http://sa.sfbay.sun.com/projects/langtools_data/mustang/5034571/
                                     
2006-01-26
PUBLIC COMMENTS

I tried the following code with 6u16 and it compiles fine:

class SomeClass {
   void callSomeMethodOfSomeClass() {}
}

class Test {
   public <S extends SomeClass> S getSome() { return null; }   
   void test() {
      getSome().callSomeMethodOfSomeClass();
   }
}

Please attach a complete test case that can be used to reproduce the problem.
                                     
2009-08-19



Hardware and Software, Engineered to Work Together