Name: tb29552 Date: 08/19/97
company - Human Genome Project , email - ###@###.###
Source code is as follows:
---------------------------------------
import java.io.*;
import java.util.*;
import java.lang.*;
import java.awt.*;
import java.awt.event.*;
public class Params extends Frame implements ActionListener{
private static final Font normFont = new Font("TimesRoman", Font.PLAIN, 14);
public Params(String title, Hashtable h, Params.Def[] params) {
super(title);
ScrollPane pane = new ScrollPane();
this.add("Center", pane);
Panel body = new Panel();
pane.add(body);
body.setLayout(new GridLayout(params.length, 2));
for (int i = 0; i < params.length; i++) {
Params.Def p = params[i];
body.add(new Label(p.label + ":"));
switch (p.type) {
case Params.Def.PFIELD:
TextField tf = new TextField();
body.add(tf);
tf.addActionListener(this); // <-------------------
break;
default:
System.out.println("ERROR: unknown param type");
break;
}
}
}
public void actionPerformed(ActionEvent e) {
TextField t = (TextField)e.getSource();
String s = t.getText();
System.out.println("Got text: " + s);
}
public static class Def {
/** These constants identify how the parameter appears in the
user interface--entry field, popup menu, radio button group. */
public static final int PFIELD = 0;
public static final int PPOPUP = 1;
public static final int PRADIO = 2;
/** Descriptive text displayed with the paremeter. */
public String label;
/** The name of the variable (hash table key) this parameter
sets/affects. */
public String variable;
/** If this field is non-null, the value of the parameter is
restricted to be one of the given values. */
public String[] allowed;
/** Defines the type of control (entry field, popup, etc.) this
parameter appears as. */
public int type;
public Def(String label,
String variable,
int type,
String[] allowed) {
this.label = label;
this.variable = variable;
this.type = type;
this.allowed = allowed;
}
}
public static void main(String[] argv) {
Params.Def[] p = new Params.Def[2];
p[0] = new Params.Def("Label1", "x", Params.Def.PFIELD, null);
p[1] = new Params.Def("Label2", "y", Params.Def.PFIELD, null);
Params app = new Params("Parameters", new Hashtable(), p);
app.setSize(700, 700);
app.show();
}
}
----------------------------------------
When attempting to compile, the compiler generates the
following messages:
--------------------------------------
{kmcdona}watcs:/home1/avery/kmcdona/fpa2{354}> javac -depend Params.java
sun.tools.java.CompilerError: addReference Params this
at sun.tools.java.ClassDefinition.addReference(ClassDefinition.java)
at sun.tools.java.ClassDefinition.getReference(ClassDefinition.java)
at sun.tools.tree.Context.noteReference(Context.java)
at sun.tools.tree.Context.makeReference(Context.java)
at sun.tools.tree.ThisExpression.checkValue(ThisExpression.java)
at sun.tools.tree.MethodExpression.checkValue(MethodExpression.java)
at sun.tools.tree.MethodExpression.check(MethodExpression.java)
at sun.tools.tree.ExpressionStatement.check(ExpressionStatement.java)
at sun.tools.tree.Statement.checkBlockStatement(Statement.java)
at sun.tools.tree.SwitchStatement.check(SwitchStatement.java)
at sun.tools.tree.Statement.checkBlockStatement(Statement.java)
at sun.tools.tree.CompoundStatement.check(CompoundStatement.java)
at sun.tools.tree.ForStatement.check(ForStatement.java)
at sun.tools.tree.Statement.checkBlockStatement(Statement.java)
at sun.tools.tree.CompoundStatement.check(CompoundStatement.java)
at sun.tools.tree.Statement.checkMethod(Statement.java)
at sun.tools.javac.SourceField.check(SourceField.java)
at sun.tools.javac.SourceClass.checkFields(SourceClass.java)
at sun.tools.javac.SourceClass.checkInternal(SourceClass.java)
at sun.tools.javac.SourceClass.check(SourceClass.java)
at sun.tools.javac.Main.compile(Main.java)
at sun.tools.javac.Main.main(Main.java)
error: An error has occurred in the compiler; please file a bug report (http://java.sun.com/cgi-bin/bugreport.cgi).
1 error
7.36u 2.68s 0:40.39 24.8%
--------------------------------------------
Deleting or commenting out the single "addActionListener"
line (marked with an arrow) permits compilation. But
as far as I can see, this line should be correct.
company - Human Genome Project , email - ###@###.###
======================================================================
- duplicates
-
JDK-4062064 javac: sun.tools.java.CompilerError: addReference <whatever> this
-
- Closed
-