On Fri, Oct 8, 2010 at 1:16 PM, Jochen Theodorou <[email protected]> wrote:
> Alessio Stalla wrote:
> [...]
>>
>> Just to rule this out: are you sure the two classes (test and
>> G4410JavaStringProducer) are loaded by the same classloader?
>
> If I execute that from eclipse, then it is not the same loader. In case of
> the junit test I think it is. But in case of eclipse the loader for test is
> a child of the loader for the G4410JavaStringProducer class

Hmm. I doubt them being in a parent-child relationship changes
anything wrt determining whether the two classes are in the same
package. The JVM specification says [1]:

"A class or interface C is accessible to a class or interface D if and
only if either of the following conditions are true:

    * C is public.

    * C and D are members of the same runtime package (§5.3)."

And "runtime package" is so defined [2]:

"The runtime package of a class or interface is determined by the
package name and defining class loader of the class or interface".

I interpret that to mean that two classes at runtime are considered to
be in the same package if and only if they have the same package name
and they've been loaded by the very same classloader.

So, that might be the problem. Maybe with JUnit you get two classloaders too.

Cheers,
Alessio

[1] 
http://java.sun.com/docs/books/jvms/second_edition/html/ConstantPool.doc.html#75929
[2] 
http://java.sun.com/docs/books/jvms/second_edition/html/ConstantPool.doc.html#72007

-- 
You received this message because you are subscribed to the Google Groups "JVM 
Languages" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jvm-languages?hl=en.

Reply via email to