Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2015222 | 1.2.0 | William Maddox | P2 | Resolved | Fixed | 1.2beta |
private method, you either get "cannot reference this until superclass
constructor has been called" or the compiler goes into an infinite loop;
the behavior depends on whether one inner class is generated or two are.
If you remove the "private" qualifier from that method, it compiles fine.
===========================================================================
roger.lewis@Eng 1997-07-17
Synopsis: Annonymous class accessing private method hangs compiler.
Description:
Looks like a JDK 1.1 anonymous adapter accessing
a private method of an enclosing classes will
hang the compiler.
Here is the code, which compiles fine when the
visibility of the accessed method, bAction,
is changed from private to protected.
************************************************
import java.awt.*;
import java.awt.event.*;
public class PrivateTest {
Frame f;
private void bAction() {
System.out.println("Thanks for the press!");
}
public PrivateTest() {
f = new Frame();
Button b = new Button("Press Me");
b.addActionListener( new ActionListener () {
public void actionPerformed(ActionEvent e) {
bAction();
}
} );
f.add(b);
f.pack();
f.show();
}
public static void main(String args[]) {
new PrivateTest();
}
}
************************************************
Here's where it hangs:
112 S% javac -verbose PrivateTest.java
[parsed PrivateTest.java in 672 ms]
[loaded E:\JDK1.1.3\lib\classes.zip(java/lang/Object.class) in 47 ms]
[checking class PrivateTest]
[loaded E:\JDK1.1.3\lib\classes.zip(java/awt/Frame.class) in 63 ms]
[loaded E:\JDK1.1.3\lib\classes.zip(java/lang/System.class) in 47 ms]
[loaded E:\JDK1.1.3\lib\classes.zip(java/io/PrintStream.class) in 32 ms]
[loaded E:\JDK1.1.3\lib\classes.zip(java/lang/String.class) in 62 ms]
[loaded E:\JDK1.1.3\lib\classes.zip(java/io/Serializable.class) in 16 ms]
[loaded E:\JDK1.1.3\lib\classes.zip(java/io/FilterOutputStream.class) in 0 ms]
[loaded E:\JDK1.1.3\lib\classes.zip(java/io/OutputStream.class) in 0 ms]
[loaded E:\JDK1.1.3\lib\classes.zip(java/awt/Window.class) in 62 ms]
[loaded E:\JDK1.1.3\lib\classes.zip(java/awt/Container.class) in 94 ms]
[loaded E:\JDK1.1.3\lib\classes.zip(java/awt/Component.class) in 172 ms]
[loaded E:\JDK1.1.3\lib\classes.zip(java/awt/Component$NativeInLightFixer.class)
in 16 ms]
[loaded E:\JDK1.1.3\lib\classes.zip(java/awt/Button.class) in 31 ms]
[loaded E:\JDK1.1.3\lib\classes.zip(java/awt/event/ActionListener.class) in 16 m
s]
[checking class PrivateTest. 1]
[loaded E:\JDK1.1.3\lib\classes.zip(java/util/EventListener.class) in 0 ms]
[loaded E:\JDK1.1.3\lib\classes.zip(java/awt/event/ActionEvent.class) in 16 ms]
================================================================================
daniel.indrigo@Canada 1997-08-26 Still doesn't work on Solaris with 1.1.3 1.1.4 or 1.2_ea2
here's the example
The compiler never stops when compiling the Java source code included below
(tried for at least 10 minutes on a Sun Ultra-1). If the line containing "int
i;" is left out, the compiler does not loop but exits with message:
CompilerLoop.java:30: Can't reference this before the superclass constructor has been called.
method2();
^
Java source code:
class A
{
void method1()
{
class Inner
{
void innerMethod()
{
method2();
}
};
int i;
}
private void method2()
{
}
}
company - Technical University of Delft, The Netherlands , email - ###@###.###
==============================================================================
john.bui@eng 1997-10-17
No specific test case available. Implicity tested, closed with exposure.
- backported by
-
JDK-2015222 Problem compiling when inner class references a private method
-
- Resolved
-
- duplicates
-
JDK-4056772 compiler hangs
-
- Closed
-
-
JDK-4059604 javac hangs
-
- Closed
-
-
JDK-4060442 javac hangs
-
- Closed
-
-
JDK-4082801 Inner Class hangs when inner class tries to access private method
-
- Closed
-
-
JDK-4034664 Innerclasses can access private fields of enclosing instance, but not private me
-
- Closed
-
-
JDK-4042464 Compiler loops on illegal input involving inner classes
-
- Closed
-
-
JDK-4044231 compiler goes in CPU loop accessing private methods from nested anonymous class
-
- Closed
-
-
JDK-4059545 javac hangs with inner class code
-
- Closed
-
-
JDK-4059555 javac hangs when compiling file
-
- Closed
-
-
JDK-4059619 Compiler hangs (no output) on given source code (anon. inner classes + serial?)
-
- Closed
-
-
JDK-4074190 Compiler will not stop when compiling anonymous class that uses private method.
-
- Closed
-
-
JDK-4046156 javac halted after loading ItemEvent.class declared in an anonymous class
-
- Closed
-