IllegalAccess in mixin field override #949
brian
31 Jan 2010
Promoted to ticket #949 and assigned to brian
Its definitely a bug somewhere in how the class is overriding the mixin field.
brian
31 Jan 2010
Renamed from Bug or PEBKAC? to IllegalAccess in mixin field override
tactics
8 Mar 2010
I narrowed down the problem a little more. It's an issue with making the objs slot internal. Remove the internal keyword from the slot and its override, and the code works normally.
mixin Collection
{
abstract internal Obj[] objs
Obj add(Obj obj)
{
objs.add(obj)
return obj
}
}
class ListCollection : Collection
{
override internal Obj[] objs := [,]
}
class Main
{
Void main()
{
list := ListCollection()
list.add("ASD")
}
}
brian
23 Mar 2010
-
brian
23 Mar 2010
Ticket resolved in 1.0.52
This issue is rather tricky.
In Java, the members of an interface must be public (they cannot be package private).
It also seems that if a class overrides an interface's public method using a package private method, then Java throws IllegalAccessError.
So effectively it is impossible to really map Fantom's internal modifier to Java's package private.
Instead I flipped so that Fantom internal slots always emit as Java public members.
tactics
23 Mar 2010
Was the original intention to keep scope modifiers consistent with the hosting language?
brian
23 Mar 2010
Was the original intention to keep scope modifiers consistent with the hosting language?
Well if possible to keep it close. Although in reality Fantom internal might be more like "module" scope in Java-7 assuming that happens.
msl
31 Jan 2010
I'm trying to assemble a hierarchy that looks something like:
mixin BottomMI { abstract internal Obj[] objs } mixin MiddleMI : BottomMI { Obj addObj(Obj obj) { objs.add(obj) return obj } } abstract class MiddleCL : MiddleMI { override internal Obj[] objs := [,] abstract Void doSomething() } class TopCL : MiddleCL { override Void doSomething() { echo("Doing something") } }However, when I try to use these classes (built into a pod by the standard build::BuildPod class - not that this seems to matter as putting all of the code listed here into a single file and running it behaves much the same, as does fansh) using code such as:
using bugquestionmark class Test { Void main() { tc := TopCL() tc.doSomething() tc.addObj("ASD") } }I get the following:
The error is obviously around visibility of the declared Obj[] (internal) but my understanding of internal is that other classes within the same pod should be able to see but not outside of the pod - criteria which are met by this sample.
Thoughts?
Martin