RFR: JDK-8136893: Improve early java.lang.invoke infrastructure initialization

Peter Levart peter.levart at gmail.com
Fri Sep 25 06:46:06 UTC 2015


Hi,

I propose a simple fix for two initialization issues described/linked in:

https://bugs.openjdk.java.net/browse/JDK-8136893

The patch is here:

http://cr.openjdk.java.net/~plevart/jdk9-dev/8136893_MethodType.fromDescriptor/webrev.01/

The 1st issue is the method: MetodType.fromMethodDescriptorString(String 
descriptor, ClassLoader loader)

This method is specified to treat null ClassLoader parameter as the 
system class loader. When lava.lang.invoke infrastructure is initialized 
before system class loader has been set, we get exceptions:

http://mail.openjdk.java.net/pipermail/mlvm-dev/2015-March/006386.html

java.lang.invoke initialization should not need to use system class 
loader as all types it must resolve during initialization are resolvable 
by bootstrap loader. Above method is public API and we can't change it's 
behavior, but can introduce another internal method that behaves a 
little differently - treating null ClassLoader as bootstrap class 
loader. All internal usages are rerouted to this internal method.

The 2nd issue is a little utility method: 
TypeConvertingMethodAdapter.boxingDescriptor(Wrapper w)

It uses String.format() to format a method type descriptor from two 
components. This unnecessarily brings in the Locale infrastructure which 
needs system class loader to locate providers:

http://mail.openjdk.java.net/pipermail/mlvm-dev/2015-March/006387.html

The fix is to replace String.format with simple string concatenation.

I have run the tests in java.lang.invoke and only have a problem with 1 
test which seems to be related to the test or jtreg itself and happens 
also without my patch applied:

#Test Results (version 2)
#Tue Sep 22 09:48:38 CEST 2015
#-----testdescription-----
$file=/home/peter/work/hg/jdk9-dev/jdk/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java
$root=/home/peter/work/hg/jdk9-dev/jdk/test
author=kshefov
error=Parse Exception\: `@library' must appear before first `@run'
keywords=bug8046703 randomness othervm ignore
run=USER_SPECIFIED ignore 8078602\nUSER_SPECIFIED build 
TestMethods\nUSER_SPECIFIED build LambdaFormTestCase\nUSER_SPECIFIED 
build LFGarbageCollectedTest\nUSER_SPECIFIED main/othervm -Xmx64m 
-XX\:SoftRefLRUPolicyMSPerMB\=0 -XX\:+HeapDumpOnOutOfMemoryError 
-DHEAP_DUMP\=false LFGarbageCollectedTest\n
source=LFGarbageCollectedTest.java
title=Test verifies that lambda forms are garbage collected

#-----environment-----

#-----testresult-----
description=file\:/home/peter/work/hg/jdk9-dev/jdk/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java
elapsed=2 0\:00\:00.002
end=Tue Sep 22 09\:48\:38 CEST 2015
environment=regtest
execStatus=Error. Parse Exception\: `@library' must appear before first 
`@run'
harnessLoaderMode=Classpath Loader
harnessVariety=Full Bundle
hostname=peterl.marand.si
javatestOS=Linux 4.1.5-100.fc21.x86_64 (amd64)
javatestVersion=4.6
jtregVersion=jtreg 4.2.0 dev tip
script=com.sun.javatest.regtest.RegressionScript
sections=script_messages
start=Tue Sep 22 09\:48\:38 CEST 2015
test=java/lang/invoke/LFCaching/LFGarbageCollectedTest.java
totalTime=2
user.name=peter
work=/home/peter/work/hg/jdk9-dev/jdk/JTwork/java/lang/invoke/LFCaching

#section:script_messages
----------messages:(0/0)----------


test result: Error. Parse Exception: `@library' must appear before first 
`@run'



Regards, Peter



More information about the mlvm-dev mailing list