problem with anonymous inner classes

Roland.Hautz root@roland.evosys.de
Tue Mar 12 07:36:00 GMT 2002


Hello,

am I right assuming the following problem with anonymous inner classes is a
known issue?

The Error message with gcj (GCC) 3.2 20020303 (experimental) is:
roland@isabella:~/work> gcj -C Test.java
IntProcedure.java: In class `Test$1':
IntProcedure.java: In constructor `(Test,int)':
IntProcedure.java:28: Local variable `parm$value' can't be accessed from within the inner class `Test$1' unless it is declared final.
   <<file too short - unexpected EOF>>
   ^
IntProcedure.java:1: internal error in generate_bytecode_insn - tree code not implemented: error_mark
1 error

Here are the testcase sources:

IntProcedure.java:
public interface IntProcedure {
    abstract public boolean apply(int element);
}

Test.java:
import IntProcedure;

public abstract class Test {

    abstract public boolean anonym(IntProcedure proc);
    
    public boolean containsValue(final int value) {
	return anonym(
		new IntProcedure() {
			public boolean apply(int iterKey) {
			    return (value != iterKey);
			}
		}
	);
    }

    public boolean containsKey(final int key) {
	return anonym(
		new IntProcedure() {
			public boolean apply(int key) {
			    return (key > 0);
			}
		}
	);
    }

}



--===-... And it is said ...-=+=-----... Superstition bears adversity ...---===
Dipl.-Phys. Roland Hautz      |Tel.:+49=8631-163136      R.Hautz@inn-salzach.de
                              |PGP public key 1024D/F5F6E1B2; key fingerprint :
Software Engineer             |5FB26673  5DE47D25  226D0ABA  E4528AB5  F5F6E1B2



More information about the Java mailing list