RFR: JDK-8179531: JShell: fails to provide bytecode for dynamically created lambdas

Paul Sandoz paul.sandoz at oracle.com
Thu May 4 17:32:48 UTC 2017


> On 4 May 2017, at 06:44, Jan Lahoda <jan.lahoda at oracle.com> wrote:
> 
> Hi,
> 
> This makes ClassLoader.getResource(s) return the actual bytecode that is being run.
> 
> Bug:
> https://bugs.openjdk.java.net/browse/JDK-8179531
> 
> Webrev:
> http://cr.openjdk.java.net/~jlahoda/8179531/webrev.00/
> 

Looks good. Minor comments.


DefaultLoaderDelegate
—

  68         private final Map<String, ClassFile> classFiles = new TreeMap<>();

HashMap?


 187                 } catch (MalformedURLException ex) {
 188                 }


Rather than swallowing the exception you might wanna throw an InternalError. I don’t think there are any valid resource names that used in a raw manner would result in the creation of a malformed URL, but just in case… I am a little paranoid about this, so would create a URI instance from the component parts, and then pass the result of toString to the URL constructor, thereby ensuring correct escaping of the resource name as the URL path. Up to you.


GetResourceTest
—

 118         Thread.sleep(1000); //ensure time change:

The test might intermittently fail. Recommend you wrap in try/catch (InterruptedException e ) {}


 136     public void checkFieldAccess() throws InterruptedException {

 152     public void checkGetResources() throws InterruptedException {

I don’t see how those methods throw InterruptedException.

Paul.


More information about the kulla-dev mailing list