[ 
https://issues.apache.org/jira/browse/DERBY-7006?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16649095#comment-16649095
 ] 

Rick Hillegas commented on DERBY-7006:
--------------------------------------

Additional complexity of solution S2:

Each jar file in the database is loaded by its own instance of 
org.apache.derby.impl.services.reflect.JarLoader. Every Java ClassLoader 
defines its own unnamed module. So, in addition to the catch-all unnamed module 
associated with the application ClassLoader, there is an unnamed module for 
each jar file in the database. It is that jar-specific unnamed module which 
cannot be read by the generated module defined by solution S2. Named modules 
cannot read unnamed modules, and java.lang.module.ModuleDescriptor.Builder 
provides no support for allowing a generated module to access an unnamed module.

The following script demonstrates this issue.

{noformat}
connect 'jdbc:derby:memory:db;create=true';

call 
sqlj.install_jar('/Users/rhillegas/derby/mainline/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/store/brtestjar.jar',
 'aggjar', 0);

call SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('derby.database.classpath', 
'APP.aggjar');

create function dv(P1 INT) RETURNS INT NO SQL external name 
'dbytesting.CodeInAJar.doubleMe' language java parameter style java;

-- fails because the generated module cannot read the unnamed
-- module associated with the JarLoader for APP.aggjar
values dv(3);

-- fails because the generated module cannot read the unnamed
-- module associated with the JarLoader for APP.aggjar
values dv(3) + dv(5);
{noformat}

Here is the output from running that script:

{noformat}
ij version 10.15
ij> connect 'jdbc:derby:memory:db;create=true';
ij> call 
sqlj.install_jar('/Users/rhillegas/derby/mainline/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/store/brtestjar.jar',
 'aggjar', 0);
0 rows inserted/updated/deleted
ij> call SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('derby.database.classpath', 
'APP.aggjar');
0 rows inserted/updated/deleted
ij> create function dv(P1 INT) RETURNS INT NO SQL external name 
'dbytesting.CodeInAJar.doubleMe' language java parameter style java;
0 rows inserted/updated/deleted
ij> -- fails because the generated module cannot read the unnamed
-- module associated with the JarLoader for APP.aggjar
values dv(3);
1          
-----------
ERROR 38000: The exception 'java.lang.IllegalAccessError: class 
org.apache.derby.exe.ac3ea3c0fbx0166x6f01xaed2xffffe268f3f22 (in module 
org.apache.derby.generatedclasses) cannot access class dbytesting.CodeInAJar 
(in unnamed module @0x1c025cb) because module org.apache.derby.generatedclasses 
does not read unnamed module @0x1c025cb' was thrown while evaluating an 
expression.
ERROR XJ001: Java exception: 'class 
org.apache.derby.exe.ac3ea3c0fbx0166x6f01xaed2xffffe268f3f22 (in module 
org.apache.derby.generatedclasses) cannot access class dbytesting.CodeInAJar 
(in unnamed module @0x1c025cb) because module org.apache.derby.generatedclasses 
does not read unnamed module @0x1c025cb: java.lang.IllegalAccessError'.
ij> -- fails because the generated module cannot read the unnamed
-- module associated with the JarLoader for APP.aggjar
values dv(3) + dv(5);
1          
-----------
ERROR 38000: The exception 'java.lang.IllegalAccessError: class 
org.apache.derby.exe.ac3ea3c0fbx0166x6f01xaed2xffffe268f3f23 (in module 
org.apache.derby.generatedclasses) cannot access class dbytesting.CodeInAJar 
(in unnamed module @0x1c025cb) because module org.apache.derby.generatedclasses 
does not read unnamed module @0x1c025cb' was thrown while evaluating an 
expression.
ERROR XJ001: Java exception: 'class 
org.apache.derby.exe.ac3ea3c0fbx0166x6f01xaed2xffffe268f3f23 (in module 
org.apache.derby.generatedclasses) cannot access class dbytesting.CodeInAJar 
(in unnamed module @0x1c025cb) because module org.apache.derby.generatedclasses 
does not read unnamed module @0x1c025cb: java.lang.IllegalAccessError'.
{noformat}


> Investigate putting generated classes under the engine module loader
> --------------------------------------------------------------------
>
>                 Key: DERBY-7006
>                 URL: https://issues.apache.org/jira/browse/DERBY-7006
>             Project: Derby
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 10.15.0.0
>            Reporter: Rick Hillegas
>            Priority: Major
>         Attachments: derby-7006-01-aa-remiForax.diff, 
> derby-7006-01-ac-alanBateman.diff
>
>
> Right now, the generated query plans are compiled into the catch-all unnamed 
> module. This forces us to grant reflective access to several engine packages. 
> It would be nice to encapsulate the generated classes inside the engine 
> module loader.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to