You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ce...@apache.org on 2022/06/14 14:04:26 UTC

svn commit: r1901904 - /xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java

Author: centic
Date: Tue Jun 14 14:04:26 2022
New Revision: 1901904

URL: http://svn.apache.org/viewvc?rev=1901904&view=rev
Log:
XMLBEANS-612: Adjust classloading for better Android support

Using Classloader.getResource() for .class-files fails on Android where
the special classloader does not return class-files as resources.

As this is only done as pre-check here if loading the class will work, 
we can replace it with catching a ClassNotFoundException instead to 
only use proper reflection functionality and thus make this 
work on Android as well.

Modified:
    xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java?rev=1901904&r1=1901903&r2=1901904&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java Tue Jun 14 14:04:26 2022
@@ -152,14 +152,13 @@ public class SchemaTypeLoaderImpl extend
         for (String prefix : basePackage) {
             for (String holder : baseSchemas) {
                 String clName = prefix + ".system." + holder + ".TypeSystemHolder";
-                if (cl.getResource(clName.replace(".", "/") + ".class") == null) {
-                    // if the first class isn't found in the package, continue with the next package
-                    break;
-                }
                 try {
                     @SuppressWarnings("unchecked")
                     Class<? extends SchemaTypeLoader> cls = (Class<? extends SchemaTypeLoader>) Class.forName(clName, true, cl);
                     list.add((SchemaTypeLoader) cls.getDeclaredField("typeSystem").get(null));
+                } catch (ClassNotFoundException e) {
+                    // if this class isn't found in the package, continue with the next package
+                    // this can happen and thus is ignored here
                 } catch (Exception e) {
                     throw new XmlRuntimeException(e);
                 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org