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

class literal in if statement with empty body causes NullPointerException.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.2.0
    • 1.1.3, 1.1.6, 1.1.7, 1.2.0
    • tools
    • 1.2beta4
    • generic, x86, sparc
    • generic, solaris_2.5.1, solaris_2.6, windows_nt
    • Not verified

      I think this is user error, but the compiler requested I file this report.

      The following java code doesn't compiler:

      public class test2
      {
              static Class m_c = Character.class;

              void xxx(Class c)
              {
                      if (c == Character.class)
                      {
                      }
              }

      }

      It fails with the following traceback:

      wildhorses% javac test2.java
      java.lang.NullPointerException
              at sun.tools.tree.ConditionalExpression.costInline(ConditionalExpression.java)
              at sun.tools.tree.ExpressionStatement.costInline(ExpressionStatement.java)
              at sun.tools.java.FieldDefinition.cleanup(FieldDefinition.java)
              at sun.tools.java.ClassDefinition.cleanup(ClassDefinition.java)
              at sun.tools.javac.Main.compile(Main.java)
              at sun.tools.javac.Main.main(Main.java)
      error: An exception has occurred in the compiler; please file a bug report (http://java.sun.com/cgi-bin/bugreport.cgi).
      1 error

      But if you change (c == Character.class) to (c.equals(Character.class))
      it compiles.

      Or if you change (c == Character.class) to (c == m_c) it compiles.


      janet.koenig@Eng 1997-08-05

            tturnidgsunw Todd Turnidge (Inactive)
            jkoenigsunw Janet Koenig (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: