The tests' use of either bootclasspath or the -endorseddirs mechanism has 
apparently been unnecessary since the Sun's acceptance of the  JAXP/TrAX plugin 
mechanisms circa Java 1.5. Certainly by Java 1.8 they moved the copies of 
Apache code they were shipping into com.sun.org.apache so there should no 
longer be a conflict.

I have proposed on the dev list that we remove this path-overriding 
complication from xalan-test, and that we remind users that they can do 
likewise.

Until we and they do make that change, this appears to be necessary and 
harmless as a short-term solution.

Unless there is a practical, as opposed to theoretical/stylistic reason, that 
it would cause trouble. I intend to accept it.


--
   /_  Joe Kesselman (he/him/his)
-/ _) My Alexa skill for New Music/New Sounds fans:
   /   https://www.amazon.com/dp/B09WJ3H657/

Caveat: Opinionated old geezer with overcompensated writer's block. May be 
redundant, verbose, prolix, sesquipedalian, didactic, officious, or redundant.
________________________________
From: vlsi (via GitHub) <g...@apache.org>
Sent: Saturday, November 25, 2023 8:53:49 AM
To: dev@xalan.apache.org <dev@xalan.apache.org>
Subject: Re: [PR] Use system class loader as a fallback to load version number 
resources [xalan-java]


vlsi commented on code in PR #129:
URL: https://github.com/apache/xalan-java/pull/129#discussion_r1405003273


##########
serializer/src/main/java/org/apache/xml/serializer/Version.java:
##########
@@ -55,7 +55,16 @@ public final class Version

   private static void readProperties() {
     Properties pomProperties = new Properties();
-    try (InputStream fromResource = 
Version.class.getClassLoader().getResourceAsStream(POM_PROPERTIES_PATH)) {
+    ClassLoader classLoader = Version.class.getClassLoader();
+    if (classLoader == null) {
+      // Oops! Someone put Xalan is on the bootstrap class loader (BCL) -> fall
+      // back to the system class loader, because there is no Classloader
+      // instance for the BCL (native code). Due to class loader hierarchy,
+      // however, the resource will also be found when asking for it from a
+      // level below the BCL.
+      classLoader = ClassLoader.getSystemClassLoader();
+    }
+    try (InputStream fromResource = 
classLoader.getResourceAsStream(POM_PROPERTIES_PATH)) {

Review Comment:
   This is [all wrong](https://www.youtube.com/watch?v=ie2V8fWqer4)

   Have you considered ~using a template Version.java~  
`Version.class.getResourceAsStream(...)`?



--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@xalan.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@xalan.apache.org
For additional commands, e-mail: dev-h...@xalan.apache.org

Reply via email to