polygene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niclas Hedhman <nic...@hedhman.org>
Subject Re: Non-Accessible Public Method??
Date Fri, 09 Jun 2017 05:50:53 GMT
Also, I think that this will go away when the classloading is fixed (if it
can be fixed)

Just to give some history for those who weren't around;

When we set out back in 2006 to do Qi4j, one of the starting points was to
not need any particular classloading approach, classes were always supposed
to be loaded by regular code, and never call ClassLoader.loadClass(). That
was the idea and it served us quite well, until the introduction of
FragmentClassLoader (and we also have TransientClassLoader for an
unfinished feature), needed to unify behavior when calling methods
externally or internally, i.e. the redirection of this.methodCall() to the
methodCall() of the composite.
And when that was done, the lack of classloading strategy became a burden,
with the solution being somewhat hacky as we needed to support both J2EE as
well as OSGi classloading.


Cheers
Niclas

On Fri, Jun 9, 2017 at 12:04 PM, Niclas Hedhman <niclas@hedhman.org> wrote:

> Wow!!!
>
> If I had read the exception a bit clearer, I would probably have gotten
> this sooner.
>
> The return type is not public, and since the _Stud is in a different class
> space, it is not accessible.
>
> Since I am probably one of the few in the world who don't make every class
> public, this is probably a small concern. But I will try to put in a more
> reasonable error message.
>
>
> Cheers
> Niclas
>
> On Fri, Jun 9, 2017 at 11:31 AM, Niclas Hedhman <niclas@hedhman.org>
> wrote:
>
>> Noooo... That was the Proxy of the mixin, that had the application
>> classloader. Of course....
>>
>> Continue to dig in this.
>>
>> On Fri, Jun 9, 2017 at 11:11 AM, Niclas Hedhman <niclas@hedhman.org>
>> wrote:
>>
>>> Ok, so I have traced this down to;
>>>
>>> The private mixin sqlTable is loaded by the Application/System
>>> classloader, but the public mixin is loaded by the Fragment classloader.
>>>
>>> The test that I tried to replicate this problem, both are loaded with
>>> the Fragment classloader.
>>>
>>> So, there is something here that triggers/prevents the fragment
>>> classloader to be used. Should not be impossible to track that down.
>>>
>>>
>>> Cheers
>>>
>>> On Wed, Jun 7, 2017 at 6:00 PM, Niclas Hedhman <niclas@hedhman.org>
>>> wrote:
>>>
>>>>
>>>> I am inclined to think it is somehow related to the classloaders. There
>>>> is one classloader per mixin type, which doesn't seem right. And I can't
>>>> manage to trigger it in a test either, although the code in question is not
>>>> that convoluted.
>>>>
>>>> In essence, 2 private Mixins inside a service, and one of them
>>>> (SqlTable) also refers to the other (jooqDslContext). Perhaps it really is
>>>> classloading issues, and maybe I have just found a breaking case. And the
>>>> course of action would be to work around the issue now, and schedule
>>>> ClassLoader renovation for 3.1
>>>>
>>>> public class JooqEntityStoreMixin
>>>>     implements EntityStore, EntityStoreSPI, ServiceActivation
>>>> {
>>>>
>>>>     @This
>>>>     private SqlTable sqlTable;
>>>>
>>>>     @This
>>>>     private JooqDslContext jooqDslContext;
>>>>
>>>>
>>>> @Override
>>>> public EntityState entityStateOf( EntityStoreUnitOfWork unitOfWork, ModuleDescriptor
module, EntityReference reference )
>>>> {
>>>>     BaseEntity baseEntity = sqlTable.fetchBaseEntity( reference, module );
 // Problem happens here...
>>>>
>>>>
>>>>
>>>> @Mixins( SqlTable.Mixin.class )
>>>> public interface SqlTable
>>>> {
>>>>     BaseEntity fetchBaseEntity( EntityReference reference, ModuleDescriptor
module );
>>>>
>>>>
>>>>     class Mixin
>>>>         implements SqlTable, Initializable, TableFields
>>>>     {
>>>>
>>>>         @Structure
>>>>         private Application application;
>>>>
>>>>         @Structure
>>>>         private ObjectFactory objectFactory;
>>>>
>>>>         @This
>>>>         private JooqDslContext dsl;
>>>>
>>>>         @This
>>>>         private Configuration<JooqEntityStoreConfiguration> configuration;
>>>>
>>>>         @Uses
>>>>         private ServiceDescriptor serviceDescriptor;
>>>>
>>>>         @Service
>>>>         private DataSource datasource;
>>>>
>>>>         private Schema schema;
>>>>
>>>>         private SQLDialect dialect;
>>>>
>>>>         private EntitiesTable entitiesTable;
>>>>         private TypesTable types;
>>>>
>>>>         @Override
>>>>         public BaseEntity fetchBaseEntity( EntityReference reference, ModuleDescriptor
module )
>>>>         {
>>>>             return entitiesTable.fetchBaseEntity( reference, module );
>>>>         }
>>>>
>>>>
>>>> java.lang.IllegalAccessError: tried to access class org.apache.polygene.entitystore.jooq.BaseEntity
from class org.apache.polygene.entitystore.jooq.SqlTable_Mixin_Stub
>>>> 	at org.apache.polygene.entitystore.jooq.SqlTable_Mixin_Stub._fetchBaseEntity(Unknown
Source)
>>>> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>>>> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>>> 	at java.lang.reflect.Method.invoke(Method.java:498)
>>>> 	at org.apache.polygene.runtime.composite.TypedModifierInvocationHandler.invoke(TypedModifierInvocationHandler.java:37)
>>>> 	at org.apache.polygene.runtime.composite.CompositeMethodInstance.invoke(CompositeMethodInstance.java:66)
>>>> 	at org.apache.polygene.runtime.composite.TransientInstance.invoke(TransientInstance.java:124)
>>>> 	at org.apache.polygene.runtime.composite.CompositeMethodModel.invoke(CompositeMethodModel.java:116)
>>>> 	at org.apache.polygene.runtime.composite.CompositeMethodsModel.invoke(CompositeMethodsModel.java:119)
>>>> 	at org.apache.polygene.runtime.composite.CompositeModel.invoke(CompositeModel.java:235)
>>>> 	at org.apache.polygene.runtime.composite.TransientInstance.invoke(TransientInstance.java:60)
>>>> 	at com.sun.proxy.$Proxy50.fetchBaseEntity(Unknown Source)
>>>> 	at org.apache.polygene.entitystore.jooq.JooqEntityStoreMixin.entityStateOf(JooqEntityStoreMixin.java:79)
>>>> 	at org.apache.polygene.entitystore.jooq.JooqEntityStoreMixin_Stub._entityStateOf(Unknown
Source)
>>>> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>>>> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>>> 	at java.lang.reflect.Method.invoke(Method.java:498)
>>>> 	at org.apache.polygene.runtime.composite.TypedModifierInvocationHandler.invoke(TypedModifierInvocationHandler.java:37)
>>>> 	at org.apache.polygene.runtime.composite.CompositeMethodInstance.invoke(CompositeMethodInstance.java:66)
>>>> 	at org.apache.polygene.runtime.composite.TransientInstance.invoke(TransientInstance.java:124)
>>>> 	at org.apache.polygene.runtime.composite.CompositeMethodModel.invoke(CompositeMethodModel.java:116)
>>>> 	at org.apache.polygene.runtime.composite.CompositeMethodsModel.invoke(CompositeMethodsModel.java:119)
>>>> 	at org.apache.polygene.runtime.composite.CompositeModel.invoke(CompositeModel.java:235)
>>>> 	at org.apache.polygene.runtime.composite.TransientInstance.invokeComposite(TransientInstance.java:81)
>>>> 	at org.apache.polygene.entitystore.jooq.JooqEntityStoreMixin_Stub.entityStateOf(Unknown
Source)
>>>> 	at org.apache.polygene.spi.entitystore.DefaultEntityStoreUnitOfWork.entityStateOf(DefaultEntityStoreUnitOfWork.java:106)
>>>>
>>>> at org.apache.polygene.spi.entitystore.ConcurrentModificationCh
>>>> eckConcern$ConcurrentCheckingEntityStoreUnitOfWork.entitySta
>>>> teOf(ConcurrentModificationCheckConcern.java:189) at
>>>> org.apache.polygene.runtime.unitofwork.UnitOfWorkInstance.get(UnitOfWorkInstance.java:138)
>>>> at org.apache.polygene.runtime.unitofwork.ModuleUnitOfWork.get(ModuleUnitOfWork.java:301)
>>>> at org.apache.polygene.runtime.unitofwork.ModuleUnitOfWork_Stub._get(Unknown
>>>> Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>>>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>>> at java.lang.reflect.Method.invoke(Method.java:498) at
>>>> org.apache.polygene.runtime.composite.TypedModifierInvocatio
>>>> nHandler.invoke(TypedModifierInvocationHandler.java:37) at
>>>> org.apache.polygene.runtime.composite.CompositeMethodInstanc
>>>> e.invoke(CompositeMethodInstance.java:66) at
>>>> org.apache.polygene.runtime.composite.TransientInstance.invoke(TransientInstance.java:124)
>>>> at org.apache.polygene.runtime.composite.CompositeMethodModel.i
>>>> nvoke(CompositeMethodModel.java:116) at org.apache.polygene.runtime.co
>>>> mposite.CompositeMethodsModel.invoke(CompositeMethodsModel.java:119)
>>>> at org.apache.polygene.runtime.composite.CompositeModel.invoke(CompositeModel.java:235)
>>>> at org.apache.polygene.runtime.composite.TransientInstance.invoke(TransientInstance.java:60)
>>>> at com.sun.proxy.$Proxy17.get(Unknown Source) at
>>>> org.apache.polygene.test.entity.AbstractEntityStoreTest.give
>>>> nEntityIsNotModifiedWhenUnitOfWorkCompletesThenDontStoreStat
>>>> e(AbstractEntityStoreTest.java:338) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
>>>> Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>>>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>>> at java.lang.reflect.Method.invoke(Method.java:498) at
>>>> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
>>>> at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
>>>> at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
>>>> at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
>>>> at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
>>>> at org.junit.internal.runners.statements.RunAfters.evaluate(Run
>>>> Afters.java:27)
>>>>
>>>>
>>>> On Wed, Jun 7, 2017 at 5:21 PM, Niclas Hedhman <niclas@hedhman.org>
>>>> wrote:
>>>>
>>>>> Except!!!!  It is not that... It is something else...
>>>>>
>>>>> On Wed, Jun 7, 2017 at 3:40 PM, Niclas Hedhman <niclas@hedhman.org>
>>>>> wrote:
>>>>>
>>>>>> Oh... some more;
>>>>>>
>>>>>>     PropertyMapper
>>>>>>     CompositeAssemblyImpl
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Wed, Jun 7, 2017 at 3:38 PM, Niclas Hedhman <niclas@hedhman.org>
>>>>>> wrote:
>>>>>>
>>>>>>> I find it in the following places (note to myself where to fix
it
>>>>>>> later);
>>>>>>>
>>>>>>>     TransientClassLoader ( 2 places )
>>>>>>>     FragmentClassLoader ( 2 places )
>>>>>>>     ConstructorsModel (2 places)
>>>>>>>     CompositeModel
>>>>>>>     CompositeMethodModel
>>>>>>>
>>>>>>> I also suspect that the "check for public" in AccessibleObjects
>>>>>>> helper should just not be done.
>>>>>>>
>>>>>>>
>>>>>>> Since this is happening during startup, I suspect that you had
other
>>>>>>> reason than performance to make this change. Would like to hear
about it.
>>>>>>>
>>>>>>>
>>>>>>> Cheers
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Wed, Jun 7, 2017 at 3:31 PM, Niclas Hedhman <niclas@hedhman.org>
>>>>>>> wrote:
>>>>>>>
>>>>>>>>
>>>>>>>> So Paul, in commit 40d8d6de0c4c459d09ffad31110b3057d175536a
you
>>>>>>>> removed setAccessible(true) in CompositeMethodModel, on the
basis that it
>>>>>>>> is not needed. After all, the method is from an interface
and public by
>>>>>>>> default.
>>>>>>>>
>>>>>>>> But that is for some reason not true.
>>>>>>>>
>>>>>>>> https://drive.google.com/open?id=0B1oCChgcqYT7RVhvMG1oaHBJQXc
>>>>>>>> https://drive.google.com/open?id=0B1oCChgcqYT7YlRDZnRXc2VBcnc
>>>>>>>>
>>>>>>>>
>>>>>>>> and for completeness
>>>>>>>>
>>>>>>>> public interface SqlTable
>>>>>>>> {
>>>>>>>>     BaseEntity fetchBaseEntity( EntityReference reference,
ModuleDescriptor module );
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> So, I have no idea why a public interface method is not
>>>>>>>> "accessible", perhaps it is something new, or something leaking
from Java 9.
>>>>>>>>
>>>>>>>> I am also very concerned that our tests don't catch this.
I will
>>>>>>>> try to reproduce this for test setting prior to adding the
"set accessible"
>>>>>>>> to the above place. Additionally, were there any other locations
where this
>>>>>>>> was changed?
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Cheers
>>>>>>>>
>>>>>>>> On Wed, Jun 7, 2017 at 3:01 PM, Niclas Hedhman <niclas@hedhman.org>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>>
>>>>>>>>> Uhhh.... I have just found this particularly interesting
situation;
>>>>>>>>>
>>>>>>>>> https://drive.google.com/file/d/0B1oCChgcqYT7a2N5RktQNWlSQnM/view
>>>>>>>>> https://drive.google.com/open?id=0B1oCChgcqYT7aEJSeW9NdFUwaWM
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> The method has "public" modifiers (it is public in the
code), but
>>>>>>>>> the "isAccessible()" is reporting false.
>>>>>>>>>
>>>>>>>>> Anybody has any ideas on how this is possible? Is there
anywhere
>>>>>>>>> we change "accessible" to false?
>>>>>>>>>
>>>>>>>>> Cheers
>>>>>>>>> --
>>>>>>>>> Niclas Hedhman, Software Developer
>>>>>>>>> http://polygene.apache.org - New Energy for Java
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Niclas Hedhman, Software Developer
>>>>>>>> http://polygene.apache.org - New Energy for Java
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Niclas Hedhman, Software Developer
>>>>>>> http://polygene.apache.org - New Energy for Java
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Niclas Hedhman, Software Developer
>>>>>> http://polygene.apache.org - New Energy for Java
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Niclas Hedhman, Software Developer
>>>>> http://polygene.apache.org - New Energy for Java
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Niclas Hedhman, Software Developer
>>>> http://polygene.apache.org - New Energy for Java
>>>>
>>>
>>>
>>>
>>> --
>>> Niclas Hedhman, Software Developer
>>> http://polygene.apache.org - New Energy for Java
>>>
>>
>>
>>
>> --
>> Niclas Hedhman, Software Developer
>> http://polygene.apache.org - New Energy for Java
>>
>
>
>
> --
> Niclas Hedhman, Software Developer
> http://polygene.apache.org - New Energy for Java
>



-- 
Niclas Hedhman, Software Developer
http://polygene.apache.org - New Energy for Java

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message