Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jwr9V-0006Qa-QZ for pljava-dev@arkaria.postgresql.org; Sat, 18 Jul 2020 18:01:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jwr9U-0001EQ-N2 for pljava-dev@arkaria.postgresql.org; Sat, 18 Jul 2020 18:01:36 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jwr9U-0001EE-7Q for pljava-dev@lists.postgresql.org; Sat, 18 Jul 2020 18:01:36 +0000 Received: from anastigmatix.net ([68.171.219.55]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jwr9R-0005d8-FF for pljava-dev@lists.postgresql.org; Sat, 18 Jul 2020 18:01:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=anastigmatix.net; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:Cc:References:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=cc9nje/u7DEuZU2jRyjWeHYa6z4wtqYwBMHlNjfqBz8=; b=Ym2/SIaC8ht/2l1lGZAze3Thw/ XFHp2olIoKpI7yt8gjIri3xSGRrSziOIvkr56xVqgxGvuzxJN6+eVa9TaOcaGi8U2rWBme1tybLrJ tWZlVdBQcvuRWx+PgTQoCL+Kz46GeAQGzX0hE/Ur163Bx0TP9PBKQQILdaQ4TSSKA62/FxSQmEOX2 A4aJPu+PlnvO+qw+9ydRZ0DmhJhzFF/GU68TpsOV6iNtEMneUP0TLVrRcSHAVc0QGU78URAyenQ2R OD7YMEehTO60dz5K0cx9Vza12SvFBymk1/sOr5Ws0tAJ/8T7R3YNAIwCMJEzk/WrTDXNN0YYMs87T 0zMgcW7Q==; Received: from [184.19.31.139] (port=47022) by bay.acenet.us with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1jwr9N-00CBsH-Lr; Sat, 18 Jul 2020 14:01:30 -0400 Subject: Re: PL/Java new build plugin To: Kartik Ohri References: <5F0734AD.7060001@anastigmatix.net> <5F077926.2050806@anastigmatix.net> <5F07C2D5.5050904@anastigmatix.net> <5F0D35BA.30904@anastigmatix.net> <5F0E3972.5070609@anastigmatix.net> <5F0F2DA2.5090603@anastigmatix.net> <5F12FF49.6090906@anastigmatix.net> <5F12FF80.5020208@anastigmatix.net> Cc: pljava-dev@lists.postgresql.org From: Chapman Flack X-Enigmail-Draft-Status: N1110 Message-ID: <5F1338F8.6030506@anastigmatix.net> Date: Sat, 18 Jul 2020 14:01:28 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-OutGoing-Spam-Status: No, score=-95.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bay.acenet.us X-AntiAbuse: Original Domain - lists.postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - anastigmatix.net X-Get-Message-Sender-Via: bay.acenet.us: authenticated_id: chap@anastigmatix.net X-Authenticated-Sender: bay.acenet.us: chap@anastigmatix.net X-Source: X-Source-Args: X-Source-Dir: X-From-Rewrite: unmodified, already matched List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 07/18/20 13:24, Kartik Ohri wrote: > What surprised me is that the only entry in the first case is present in > the second case but still the second fails, Am I missing something here ? I am guessing a little bit from the output your code is showing without seeing the actual code, but as I refer back to the commit comments for 6cd539b, it seems that the key thing Java 9 changed was that Nashorn went from the boot classpath (the one with classloader null) to the application classpath (the one implemented by jdk.internal.loader.ClassLoaders$AppClassLoader). I don't think the Nashorn engine is found in any of the specific URLs that you see when you enumerate the classpath; it's still internal to the Java installation, somewhere the AppClassLoader just knows about. In the Maven case, I think the key thing is some change in the rule for delegating to the AppClassLoader. In the output you've shown, I assume that java.net.URLClassLoader is the one you created from explicit URL list, and you made its parent the classloader you were initially given, which would be that ClassRealm instance. I see that it has the AppClassLoader as its parent, and the "normal" Java classloading rule is you ask your parent first, then only look in your own places if the parent drew a blank. But I think the ClassRealm changes that rule in some way. There was something in that MANTRUN-200 issue suggesting they did that because they wanted Maven builds to be predictable regardless of what was on the application class path. (Which, ok, I guess, but ... seriously ... ?) But I would really like to know what ends up happening when a Maven classpathref is passed to Ant, and ends up solving the problem. What is a Maven classpathref? Is it just a list of URLs, or some other object? I wonder if it ends up working sort of by accident, maybe Ant uses the classpathref to make a more usual classloader structure that has the same URLs as the ClassRealm loader, but delegates from there to the AppClassLoader instead of the ClassRealm. That could be plausible, as Ant came first and wouldn't know about a ClassRealm. It would be good to see it in the code though. Ultimately we want a classloader that will work whether the engine is part of the application classpath (as Nashorn on Java <15) OR is in one of the explicit classpath jars (as in Java 15 if we download Graal's js-scriptengine, or if we play with jshell-scriptengine). Regards, -Chap