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

REGRESSION: Multiply defined class can cause compiler crash.

XMLWordPrintable

    • hopper
    • x86
    • windows_xp
    • Verified



      Name: ddT132432 Date: 11/26/2001


      java version "1.4.0-beta3"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b84)
      Java HotSpot(TM) Client VM (build 1.4.0-beta3-b84, mixed mode)

      1) Compile the program using the arguement -deprecation

      2)

      ---
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

      public class TextFieldLimiter extends JFrame
      {
      TextFieldLimiter()
      {
      super("TextField tester");
      JPanel panel = (JPanel)getContentPane();
      MyTextField tf = new MyTextField(10);
      panel.add(tf,BorderLayout.CENTER);
      setSize(100,75);
      setVisible(true);
      }

      public static void main(String[] args)
      {
      TextFieldTester t = new TextFieldTester();
      t.addWindowListener( new WindowAdapter()
      {
      public void windowClosing( WindowEvent e )
      {
      System.exit(0);
      }
      }
      );
      }

      }

      class MyTextField extends JTextField
      {
      protected void processKeyEvent(KeyEvent ke)
      {
      if(e.getModifiers() == 0)
      {
      int keyChar = e.getKeyChar();
      if(keyChar >= '0' && keyChar <= '9' || keyChar == '\n')
      {
      super.processKeyEvent(e);
      }
      }
      }
      }
      ---
      3)

      TextFieldTester.java:5: interface expected here
      class TextFieldLimiter extends JFrame implements KeyAdapter
                                                       ^
      TextFieldTester.java:13: cannot resolve symbol
      symbol : constructor MyTextField (int)
      location: class MyTextField
      MyTextField tf = new MyTextField(10);
                                       ^
      TextFieldTester.java:17: addKeyListener(java.awt.event.KeyListener) in
      java.awt.Component cannot be applied to (TextFieldLimiter)
      tf.addKeyListener(this);
                        ^
      .\TextFieldTester.java:5: duplicate class: TextFieldLimiter
      class TextFieldLimiter extends JFrame implements KeyAdapter
      ^
      .\TextFieldTester.java:39: duplicate class: MyTextField
      class MyTextField extends JTextField
      ^
      TextFieldTester.java:25: cannot resolve symbol
      symbol : constructor TextFieldTester ()
      location: class TextFieldTester
      TextFieldTester t = new TextFieldTester();
                                          ^
      TextFieldTester.java:27: cannot resolve symbol
      symbol : method addWindowListener (<anonymous java.awt.event.WindowAdapter>)
      location: class TextFieldTester
      t.addWindowListener( new WindowAdapter()
                       ^
      An exception has occurred in the compiler (1.4.0-beta3). Please file a bug at
      the Java Developer Connection (http://java.sun.com/cgi-bin/bugreport.cgi)
      after checking the Bug Parade for duplicates. Include your program and the
      following diagnostic in your report. Thank you.
      java.lang.ClassCastException: com.sun.tools.javac.v8.code.Type$ErrorType
      at com.sun.tools.javac.v8.comp.Resolve.instantiate(Resolve.java:203)
      at com.sun.tools.javac.v8.comp.Attr.checkId(Attr.java:1330)
      at com.sun.tools.javac.v8.comp.Attr._case(Attr.java:1226)
      at com.sun.tools.javac.v8.tree.Tree$Select.visit(Tree.java:1063)
      at com.sun.tools.javac.v8.comp.Attr.attribTree(Attr.java:259)
      at com.sun.tools.javac.v8.comp.Attr.attribExpr(Attr.java:274)
      at com.sun.tools.javac.v8.comp.Attr._case(Attr.java:833)
      at com.sun.tools.javac.v8.tree.Tree$Apply.visit(Tree.java:869)
      at com.sun.tools.javac.v8.comp.Attr.attribTree(Attr.java:259)
      at com.sun.tools.javac.v8.comp.Attr.attribExpr(Attr.java:282)
      at com.sun.tools.javac.v8.comp.Attr._case(Attr.java:661)
      at com.sun.tools.javac.v8.tree.Tree$Exec.visit(Tree.java:765)
      at com.sun.tools.javac.v8.comp.Attr.attribTree(Attr.java:259)
      at com.sun.tools.javac.v8.comp.Attr.attribStat(Attr.java:296)
      at com.sun.tools.javac.v8.comp.Attr.attribStats(Attr.java:314)
      at com.sun.tools.javac.v8.comp.Attr._case(Attr.java:462)
      at com.sun.tools.javac.v8.tree.Tree$Block.visit(Tree.java:539)
      at com.sun.tools.javac.v8.comp.Attr.attribTree(Attr.java:259)
      at com.sun.tools.javac.v8.comp.Attr.attribExpr(Attr.java:274)
      at com.sun.tools.javac.v8.comp.Attr._case(Attr.java:651)
      at com.sun.tools.javac.v8.tree.Tree$If.visit(Tree.java:748)
      at com.sun.tools.javac.v8.comp.Attr.attribTree(Attr.java:259)
      at com.sun.tools.javac.v8.comp.Attr.attribStat(Attr.java:296)
      at com.sun.tools.javac.v8.comp.Attr.attribStats(Attr.java:314)
      at com.sun.tools.javac.v8.comp.Attr._case(Attr.java:462)
      at com.sun.tools.javac.v8.tree.Tree$Block.visit(Tree.java:539)
      at com.sun.tools.javac.v8.comp.Attr.attribTree(Attr.java:259)
      at com.sun.tools.javac.v8.comp.Attr.attribExpr(Attr.java:274)
      at com.sun.tools.javac.v8.comp.Attr._case(Attr.java:651)
      at com.sun.tools.javac.v8.tree.Tree$If.visit(Tree.java:748)
      at com.sun.tools.javac.v8.comp.Attr.attribTree(Attr.java:259)
      at com.sun.tools.javac.v8.comp.Attr.attribStat(Attr.java:296)
      at com.sun.tools.javac.v8.comp.Attr.attribStats(Attr.java:314)
      at com.sun.tools.javac.v8.comp.Attr._case(Attr.java:462)
      at com.sun.tools.javac.v8.tree.Tree$Block.visit(Tree.java:539)
      at com.sun.tools.javac.v8.comp.Attr.attribTree(Attr.java:259)
      at com.sun.tools.javac.v8.comp.Attr.attribStat(Attr.java:296)
      at com.sun.tools.javac.v8.comp.Attr._case(Attr.java:415)
      at com.sun.tools.javac.v8.tree.Tree$MethodDef.visit(Tree.java:474)
      at com.sun.tools.javac.v8.comp.Attr.attribTree(Attr.java:259)
      at com.sun.tools.javac.v8.comp.Attr.attribStat(Attr.java:296)
      at com.sun.tools.javac.v8.comp.Attr.attribClass(Attr.java:1489)
      at com.sun.tools.javac.v8.comp.Attr.attribClass(Attr.java:1456)
      at com.sun.tools.javac.v8.JavaCompiler.compile(JavaCompiler.java:396)
      at com.sun.tools.javac.v8.Main.compile(Main.java:526)
      at com.sun.tools.javac.Main.compile(Main.java:32)
      at com.sun.tools.javac.Main.main(Main.java:23)
      Normal Termination
      Output completed (1 sec consumed).
      ---
      4)

      --
      5) My file was called TextFieldTester.java instead of TextFieldLimiter.java

      Release Regression From : 1.3.1
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

      (Review ID: 136028)
      ======================================================================

            gafter Neal Gafter (Inactive)
            ddressersunw Daniel Dresser (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: