Is the following legal?
From: bluke (martybluke_at_hotmail.com)
Date: 05/17/04
- Next message: Enrique: "Re: Running Jars"
- Previous message: Phillip Lord: "Re: type safety in java 1.5 (bug or hole?)"
- Next in thread: kaeli: "Re: Is the following legal?"
- Reply: kaeli: "Re: Is the following legal?"
- Reply: John C. Bollinger: "Re: Is the following legal?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 17 May 2004 10:10:54 -0700
I have the following:
package test1;
class Test {
public final Color RED = new Color("red");
protected static final class Color {
private String id;
private Color (String id) {
this.id = id;
}
public String toString() {
return id;
}
}
}
package test1;
public class Test1 extends Test {
}
package test2;
public class Test2 extends Test1 {
someMethod(RED);
}
I am getting an IllegalAccessError with this because Class Test is
package protected and Test2 is in a different package, so when Test2
tries to access RED I get an IllegalAccessError that tried to access
class test1.Test from class test2.Test2. The interesting thing about
this is that it compiles. This means that there is either a VM bug or
a compiler bug, because if it compiles I should not get an
IllegalAccessError. Is this actually legal?
- Next message: Enrique: "Re: Running Jars"
- Previous message: Phillip Lord: "Re: type safety in java 1.5 (bug or hole?)"
- Next in thread: kaeli: "Re: Is the following legal?"
- Reply: kaeli: "Re: Is the following legal?"
- Reply: John C. Bollinger: "Re: Is the following legal?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|