Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6359951

Class field usage in generic

    XMLWordPrintable

Details

    • b73
    • x86
    • linux
    • Verified

    Description

      FULL PRODUCT VERSION :
      java version "1.5.0_04"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
      Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      Linux is003029 2.6.11.10 #1 Wed Jun 1 11:36:47 CEST 2005 i686 GNU/Linux
      Windows XP

      A DESCRIPTION OF THE PROBLEM :
      The following program :

      class Foo {
          class C<T> { public static Class classOfT = T.getClass();}
          class D<T> { }
          class E<T> extends D< T.classOfT> { }
      }

      When compiled with "javac Foo.java" always yields the following error:

      java.lang.NullPointerException
              at com.sun.tools.javac.comp.Attr.selectSym(Attr.java:1774)
              at com.sun.tools.javac.comp.Attr.selectSym(Attr.java:1812)
              at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:1699)
              at com.sun.tools.javac.tree.Tree$Select.accept(Tree.java:987)
              at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
              at com.sun.tools.javac.comp.Attr.attribType(Attr.java:308)
              at com.sun.tools.javac.comp.Attr.attribTypes(Attr.java:351)
              at com.sun.tools.javac.comp.Attr.visitTypeApply(Attr.java:2212)
              at com.sun.tools.javac.tree.Tree$TypeApply.accept(Tree.java:1058)
              at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
              at com.sun.tools.javac.comp.Attr.attribType(Attr.java:308)
              at com.sun.tools.javac.comp.Attr.attribBase(Attr.java:381)
              at com.sun.tools.javac.comp.MemberEnter.complete(MemberEnter.java:792)
              at com.sun.tools.javac.code.Symbol.complete(Symbol.java:355)
              at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:612)
              at com.sun.tools.javac.comp.Enter.complete(Enter.java:448)
              at com.sun.tools.javac.comp.Enter.main(Enter.java:426)
              at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:413)
              at com.sun.tools.javac.main.Main.compile(Main.java:592)
              at com.sun.tools.javac.main.Main.compile(Main.java:544)
              at com.sun.tools.javac.Main.compile(Main.java:67)
              at com.sun.tools.javac.Main.main(Main.java:52)


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a file Foo.java which contents are:
      class Foo {
          class C<T> { public static Class classOfT = T.getClass();}
          class D<T> { }
          class E<T> extends D< T.classOfT> { }
      }
      Then try to compile the file with the command "javac Foo.java".

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I was expecting the byte code class files "Foo.class" "Foo$C.class" "Foo$D.class" "Foo$E.class" to be created.
      ACTUAL -
      Instread I get this message:
      An exception has occurred in the compiler (1.5.0_04). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade forduplicates. Include your program and the following diagnostic in your report. Thank you.
      java.lang.NullPointerException
              at com.sun.tools.javac.comp.Attr.selectSym(Attr.java:1774)
              at com.sun.tools.javac.comp.Attr.selectSym(Attr.java:1812)
              at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:1699)
              at com.sun.tools.javac.tree.Tree$Select.accept(Tree.java:987)
              at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
              at com.sun.tools.javac.comp.Attr.attribType(Attr.java:308)
              at com.sun.tools.javac.comp.Attr.attribTypes(Attr.java:351)
              at com.sun.tools.javac.comp.Attr.visitTypeApply(Attr.java:2212)
              at com.sun.tools.javac.tree.Tree$TypeApply.accept(Tree.java:1058)
              at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
              at com.sun.tools.javac.comp.Attr.attribType(Attr.java:308)
              at com.sun.tools.javac.comp.Attr.attribBase(Attr.java:381)
              at com.sun.tools.javac.comp.MemberEnter.complete(MemberEnter.java:792)
              at com.sun.tools.javac.code.Symbol.complete(Symbol.java:355)
              at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:612)
              at com.sun.tools.javac.comp.Enter.complete(Enter.java:448)
              at com.sun.tools.javac.comp.Enter.main(Enter.java:426)
              at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:413)
              at com.sun.tools.javac.main.Main.compile(Main.java:592)
              at com.sun.tools.javac.main.Main.compile(Main.java:544)
              at com.sun.tools.javac.Main.compile(Main.java:67)
              at com.sun.tools.javac.Main.main(Main.java:52)


      ERROR MESSAGES/STACK TRACES THAT OCCUR :

      An exception has occurred in the compiler (1.5.0_04). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade forduplicates. Include your program and the following diagnostic in your report. Thank you.
      java.lang.NullPointerException
              at com.sun.tools.javac.comp.Attr.selectSym(Attr.java:1774)
              at com.sun.tools.javac.comp.Attr.selectSym(Attr.java:1812)
              at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:1699)
              at com.sun.tools.javac.tree.Tree$Select.accept(Tree.java:987)
              at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
              at com.sun.tools.javac.comp.Attr.attribType(Attr.java:308)
              at com.sun.tools.javac.comp.Attr.attribTypes(Attr.java:351)
              at com.sun.tools.javac.comp.Attr.visitTypeApply(Attr.java:2212)
              at com.sun.tools.javac.tree.Tree$TypeApply.accept(Tree.java:1058)
              at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
              at com.sun.tools.javac.comp.Attr.attribType(Attr.java:308)
              at com.sun.tools.javac.comp.Attr.attribBase(Attr.java:381)
              at com.sun.tools.javac.comp.MemberEnter.complete(MemberEnter.java:792)
              at com.sun.tools.javac.code.Symbol.complete(Symbol.java:355)
              at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:612)
              at com.sun.tools.javac.comp.Enter.complete(Enter.java:448)
              at com.sun.tools.javac.comp.Enter.main(Enter.java:426)
              at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:413)
              at com.sun.tools.javac.main.Main.compile(Main.java:592)
              at com.sun.tools.javac.main.Main.compile(Main.java:544)
              at com.sun.tools.javac.Main.compile(Main.java:67)
              at com.sun.tools.javac.Main.main(Main.java:52)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      class Foo {
          class C<T> { public static Class classOfT = T.getClass();}
          class D<T> { }
          class E<T> extends D< T.classOfT> { }
      }
      ---------- END SOURCE ----------

      Attachments

        Issue Links

          Activity

            People

              ahe Peter Ahe
              rmandalasunw Ranjith Mandala (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: