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

Richard N. Hillegas commented on DERBY-7126:
--------------------------------------------

Attaching derby-7126-04-aa-makeTestsRunOnJDK11andJDK18.diff. This patch adjusts 
the tests so that they run cleanly on both JDK 11 and 18 build 18-ea+23-1525. 
With these changes, Derby builds cleanly on both JDK 11 and JDK 18--that 
includes the javadoc.

The chief challenge was that the java.security.manager property has changed 
meaning between JDK 11 and JDK 18. JDK 11 interprets the property as the name 
of a user-written class which replaces the SecurityManager. JDK 18 interprets 
the property as a gate on whether the application is allowed to install a 
SecurityManager. You CAN'T set that property when running on JDK 11 and you 
MUST set that property when running on JDK 18.

To test these changes, I built Derby with JDK 18 build 18-ea+23-1525 and ran 
the following tests on JDK 11 and JDK 18:

o The old harness tests with both the classpath and the modulepath (from my own 
scripts, setting java.security.manager=allow only if the platform was JDK 18).
o The JUnit tests with both the classpath and the modulepath (from my own 
scripts, setting java.security.manager=allow only if the platform was JDK 18).
o ant junit-all
o ant test-derbyall
o ant test-derbyall-with-modulepath
o ant test-junit-all-with-modulepath

I saw one error in XMLBindingTest when running the JUnit tests under ant. The 
error occurs when you run XMLBindingTest standalone using the junit-single 
target. The error was not introduced by my changes: it occurs when you run 
XMLBindingTest under ant on JDK 11 without my changes. This is the error:

{noformat}
  <testcase 
classname="org.apache.derbyTesting.functionTests.tests.lang.XMLBindingTest$XBindTestSetup"
 name="unknown" time="0.0">
    <error message="Invalid XML Document: access denied 
(&quot;java.io.FilePermission&quot; 
&quot;/Users/rhillegas/derby/mainline/trunk/junit_20211126_1247/extin/personal.dtd&quot;
 &quot;read&quot;)" type="java.sql.SQLDataException">java.sql.SQLDataException: 
Invalid XML Document: access denied (&quot;java.io.FilePermission&quot; 
&quot;/Users/rhillegas/derby/mainline/trunk/junit_20211126_1247/extin/personal.dtd&quot;
 &quot;read&quot;)
        at 
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:84)
        at 
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:141)
        at org.apache.derby.impl.jdbc.Util.seeNextException(Util.java:252)
        at 
org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:438)
        at 
org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:360)
        at 
org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2405)
        at 
org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:88)
        at 
org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1436)
        at 
org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(EmbedPreparedStatement.java:1709)
        at 
org.apache.derby.impl.jdbc.EmbedPreparedStatement.execute(EmbedPreparedStatement.java:1394)
        at org.apache.derbyTesting.junit.XML.insertDocWithDTD(XML.java:206)
        at 
org.apache.derbyTesting.functionTests.tests.lang.XMLBindingTest$XBindTestSetup.setUp(XMLBindingTest.java:306)
        at junit.extensions.TestSetup$1.protect(TestSetup.java:20)
        at junit.extensions.TestSetup.run(TestSetup.java:25)
        at 
org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:60)
        at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
        at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
        at junit.extensions.TestSetup.run(TestSetup.java:25)
        at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
        at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
        at junit.extensions.TestSetup.run(TestSetup.java:25)
Caused by: ERROR 2200M: Invalid XML Document: access denied 
(&quot;java.io.FilePermission&quot; 
&quot;/Users/rhillegas/derby/mainline/trunk/junit_20211126_1247/extin/personal.dtd&quot;
 &quot;read&quot;)
        at 
org.apache.derby.shared.common.error.StandardException.newException(StandardException.java:300)
        at 
org.apache.derby.impl.jdbc.SQLExceptionFactory.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory.java:170)
        at 
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:75)
Caused by: java.security.AccessControlException: access denied 
(&quot;java.io.FilePermission&quot; 
&quot;/Users/rhillegas/derby/mainline/trunk/junit_20211126_1247/extin/personal.dtd&quot;
 &quot;read&quot;)
        at 
java.base/java.security.AccessControlContext.checkPermission(AccessControlContext.java:485)
        at 
java.base/java.security.AccessController.checkPermission(AccessController.java:1068)
        at 
java.base/java.lang.SecurityManager.checkPermission(SecurityManager.java:411)
        at 
java.base/java.lang.SecurityManager.checkRead(SecurityManager.java:751)
        at java.base/java.io.File.isDirectory(File.java:860)
        at 
java.base/sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:78)
        at 
java.base/sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:189)
        at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown 
Source)
        at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source)
        at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(Unknown 
Source)
        at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(Unknown 
Source)
        at 
org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown 
Source)
        at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown 
Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
        at org.apache.derby.iapi.types.SqlXmlUtil$1.run(SqlXmlUtil.java:331)
        at org.apache.derby.iapi.types.SqlXmlUtil$1.run(SqlXmlUtil.java:328)
        at 
java.base/java.security.AccessController.doPrivileged(AccessController.java:569)
        at 
org.apache.derby.iapi.types.SqlXmlUtil.serializeToString(SqlXmlUtil.java:326)
        at org.apache.derby.iapi.types.XML.XMLParse(XML.java:630)
        at 
org.apache.derby.exe.ac3ea3c0fbx017dx5e01x2bf3x00004dfa5c450.e0(Unknown Source)
        at 
org.apache.derby.impl.services.reflect.DirectCall.invoke(ReflectGeneratedClass.java:101)
        at 
org.apache.derby.impl.sql.execute.RowResultSet.getNextRowCore(RowResultSet.java:150)
        at 
org.apache.derby.impl.sql.execute.NormalizeResultSet.getNextRowCore(NormalizeResultSet.java:188)
        at 
org.apache.derby.impl.sql.execute.DMLWriteResultSet.getNextRowCore(DMLWriteResultSet.java:148)
        at 
org.apache.derby.impl.sql.execute.InsertResultSet.getNextRowCore(InsertResultSet.java:1082)
        at 
org.apache.derby.impl.sql.execute.InsertResultSet.open(InsertResultSet.java:451)
        at 
org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:472)
        at 
org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:351)
        at 
org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1344)
</error>
  </testcase>
{noformat}

Touches the following files:

{noformat}
M       build.xml

Change the ant test targets to only set java.security.manager=allow if the JDK 
level is at least 16. I used the presence of a class introduced by JDK 16 to 
switch the behavior. Sample tests ran cleanly on JDK 16 when I did this. The 
meaning of java.security.manager must have changed in JDK 16 or earlier. I used 
the JDK 16 class because it was easy to figure out that the new class was 
introduced by that version; I could not easily find any classes introduced by 
JDK 17 or JDK 18.


M       
java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/harness/JavaVersionHolder.java

Some future-proofing to make sure that the tests continue to run up through JDK 
21.


M       
java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/harness/jvm.java
M       
java/org.apache.derby.tests/org/apache/derbyTesting/junit/BaseTestCase.java
M       
java/org.apache.derby.tests/org/apache/derbyTesting/junit/NetworkServerTestSetup.java

When spawning new JVMs, only set java.security.manager=allow if the JDK level 
is at least 18.
{noformat}


> Make it possible to build and test Derby cleanly with OpenJDK 18
> ----------------------------------------------------------------
>
>                 Key: DERBY-7126
>                 URL: https://issues.apache.org/jira/browse/DERBY-7126
>             Project: Derby
>          Issue Type: Task
>          Components: Build tools
>    Affects Versions: 10.16.0.0
>            Reporter: Richard N. Hillegas
>            Assignee: Richard N. Hillegas
>            Priority: Major
>         Attachments: DERBY_7126_A.java, DERBY_7126_B.java, dcl_emc2sm.jar, 
> derby-7126-01-aa-regenerateSignedJars.diff, 
> derby-7126-02-aa-suppressDeprecationWarnings.diff, 
> derby-7126-03-aa-mention-java.security.manager.diff, 
> derby-7126-04-aa-makeTestsRunOnJDK11andJDK18.diff
>
>
> Releases of Open JDK 18 can be found at https://jdk.java.net/178. We should 
> adjust Derby as necessary so that it builds cleanly (including javadoc) and 
> tests cleanly with this version of the platform.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to