Bump source/binary level to 11, drop MR-jar (#207)

Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
diff --git a/api/pom.xml b/api/pom.xml
index e99ae32..b7b1bc6 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -67,11 +67,6 @@
                 <plugin>
                     <artifactId>maven-javadoc-plugin</artifactId>
                     <configuration>
-                        <additionalOptions>
-                            <additionalOptions>--add-modules</additionalOptions>
-                            <additionalOptions>java.desktop</additionalOptions>
-                        </additionalOptions>
-                        <release>11</release>
                         <nodeprecated>false</nodeprecated>
                         <notimestamp>true</notimestamp>
                         <nosince>true</nosince>
@@ -146,21 +141,6 @@
                             </resources>
                         </configuration>
                     </execution>
-                    <execution>
-                        <id>add-mr-resource</id>
-                        <phase>prepare-package</phase>
-                        <goals>
-                            <goal>add-resource</goal>
-                        </goals>
-                        <configuration>
-                            <resources>
-                                <resource>
-                                    <directory>${project.basedir}/src/main/mr-jar</directory>
-                                    <targetPath>META-INF/versions/9</targetPath>
-                                </resource>
-                            </resources>
-                        </configuration>
-                    </execution>
                 </executions>
             </plugin>
             <plugin>
@@ -191,41 +171,12 @@
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-compiler-plugin</artifactId>
                 <configuration>
-                    <source>9</source>
-                    <target>9</target>
                     <compilerArgs>
                         <arg>-Xlint:all</arg>
                     </compilerArgs>
                     <showDeprecation>true</showDeprecation>
                     <showWarnings>true</showWarnings>
                 </configuration>
-                <executions>
-                    <execution>
-                        <id>default-compile-mr</id>
-                        <goals>
-                            <goal>compile</goal>
-                        </goals>
-                        <configuration>
-                            <release>9</release>
-                            <compileSourceRoots>
-                                <compileSourceRoot>${project.basedir}/src/main/mr-jar</compileSourceRoot>
-                            </compileSourceRoots>
-                            <outputDirectory>${project.build.outputDirectory}/META-INF/versions/9</outputDirectory>
-                        </configuration>
-                    </execution>
-                    <execution>
-                        <id>base-compile</id>
-                        <goals>
-                            <goal>compile</goal>
-                        </goals>
-                        <configuration>
-                            <release>8</release>
-                            <excludes>
-                                <exclude>module-info.java</exclude>
-                            </excludes>
-                        </configuration>
-                    </execution>
-                </executions>
             </plugin>
             <plugin>
                 <groupId>org.apache.felix</groupId>
@@ -244,9 +195,8 @@
                                 Jakarta XML Binding API ${spec.version} Design Specification
                             </Bundle-Description>
                             <Extension-Name>${extension.name}</Extension-Name>
-                            <Implementation-Version>${spec.version}.${impl.version}</Implementation-Version>
+                            <Implementation-Version>${project.version}</Implementation-Version>
                             <Specification-Version>${spec.version}</Specification-Version>
-                            <Export-Package>${api.package}.*; version=${spec.version}.${impl.version}</Export-Package>
                             <Import-Package>
                                 !org.glassfish.hk2.osgiresourcelocator,
                                 *
@@ -255,7 +205,6 @@
                             <DynamicImport-Package>org.glassfish.hk2.osgiresourcelocator</DynamicImport-Package>
                             <Specification-Vendor>${vendor.name}</Specification-Vendor>
                             <Implementation-Build-Id>${buildNumber}</Implementation-Build-Id>
-                            <Multi-Release>true</Multi-Release>
                         </instructions>
                     </configuration>
                     </execution>
@@ -276,7 +225,6 @@
                 <groupId>com.github.spotbugs</groupId>
                 <artifactId>spotbugs-maven-plugin</artifactId>
                 <configuration>
-                    <findbugsXmlWithMessages>true</findbugsXmlWithMessages>
                     <fork>true</fork>
                     <excludeFilterFile>${spotbugs.exclude}</excludeFilterFile>
                     <failThreshold>High</failThreshold>
diff --git a/api/src/main/java/jakarta/xml/bind/DataBindingException.java b/api/src/main/java/jakarta/xml/bind/DataBindingException.java
index ba90222..6ea2438 100644
--- a/api/src/main/java/jakarta/xml/bind/DataBindingException.java
+++ b/api/src/main/java/jakarta/xml/bind/DataBindingException.java
@@ -22,6 +22,9 @@
  * @since 1.6, JAXB 2.1
  */
 public class DataBindingException extends RuntimeException {
+
+    private static final long serialVersionUID = 4743686626270704879L;
+
     public DataBindingException(String message, Throwable cause) {
         super(message, cause);
     }
diff --git a/api/src/main/java/jakarta/xml/bind/MarshalException.java b/api/src/main/java/jakarta/xml/bind/MarshalException.java
index 8e1b6d4..cc8b199 100644
--- a/api/src/main/java/jakarta/xml/bind/MarshalException.java
+++ b/api/src/main/java/jakarta/xml/bind/MarshalException.java
@@ -27,6 +27,8 @@
  */
 public class MarshalException extends JAXBException {
 
+    private static final long serialVersionUID = 1570397297836071517L;
+
     /** 
      * Construct a MarshalException with the specified detail message.  The 
      * errorCode and linkedException will default to null.
diff --git a/api/src/main/java/jakarta/xml/bind/ModuleUtil.java b/api/src/main/java/jakarta/xml/bind/ModuleUtil.java
index b81253a..af02171 100644
--- a/api/src/main/java/jakarta/xml/bind/ModuleUtil.java
+++ b/api/src/main/java/jakarta/xml/bind/ModuleUtil.java
@@ -10,40 +10,130 @@
 
 package jakarta.xml.bind;
 
+import java.io.BufferedReader;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 /**
- * Intended to be overridden on JDK9, with JEP 238 multi-release class copy.
- * Contains only stubs for methods needed on JDK9 runtime.
+ * Propagates openness of Jakarta XML Binding annotated classes packages to Jakarta XML Binding impl module.
  *
  * @author Roman Grigoriadi
  */
 class ModuleUtil {
 
+    private static final Logger LOGGER = Logger.getLogger("jakarta.xml.bind");
+
     /**
      * Resolves classes from context path.
      * Only one class per package is needed to access its {@link java.lang.Module}
      */
     static Class<?>[] getClassesFromContextPath(String contextPath, ClassLoader classLoader) throws JAXBException {
-        return null;
+        List<Class<?>> classes = new ArrayList<>();
+        if (contextPath == null || contextPath.isEmpty()){
+            return classes.toArray(new Class<?>[]{});
+        }
+
+        String [] tokens = contextPath.split(":");
+        for (String pkg : tokens){
+
+            // look for ObjectFactory and load it
+            try {
+                final Class<?> o = classLoader.loadClass(pkg+".ObjectFactory");
+                classes.add(o);
+                continue;
+            } catch (ClassNotFoundException e) {
+                // not necessarily an error
+            }
+
+            // look for jaxb.index and load the list of classes
+            try {
+                final Class<?> firstByJaxbIndex = findFirstByJaxbIndex(pkg, classLoader);
+                if (firstByJaxbIndex != null) {
+                    classes.add(firstByJaxbIndex);
+                }
+            } catch (IOException e) {
+                throw new JAXBException(e);
+            }
+        }
+
+        if (LOGGER.isLoggable(Level.FINE)) {
+            LOGGER.log(Level.FINE, "Resolved classes from context path: {0}", classes);
+        }
+        return classes.toArray(new Class<?>[]{});
     }
 
     /**
      * Find first class in package by {@code jaxb.index} file.
      */
     static Class<?> findFirstByJaxbIndex(String pkg, ClassLoader classLoader) throws IOException, JAXBException {
+        final String resource = pkg.replace('.', '/') + "/jaxb.index";
+        final InputStream resourceAsStream = classLoader.getResourceAsStream(resource);
+
+        if (resourceAsStream == null) {
+            return null;
+        }
+
+        try (BufferedReader in = new BufferedReader(new InputStreamReader(resourceAsStream, "UTF-8"))) {
+            String className = in.readLine();
+            while (className != null) {
+                className = className.trim();
+                if (className.startsWith("#") || (className.length() == 0)) {
+                    className = in.readLine();
+                    continue;
+                }
+
+                try {
+                    return classLoader.loadClass(pkg + '.' + className);
+                } catch (ClassNotFoundException e) {
+                    throw new JAXBException(Messages.format(Messages.ERROR_LOAD_CLASS, className, pkg), e);
+                }
+
+            }
+        }
         return null;
     }
 
     /**
      * Implementation may be defined in other module than {@code jakarta.xml.bind}. In that case openness
-     * {@linkplain java.lang.Module#isOpen open} of classes should be delegated to implementation module.
+     * {@linkplain Module#isOpen open} of classes should be delegated to implementation module.
      *
-     * @param classes used to resolve module for {@linkplain java.lang.Module#addOpens(String, java.lang.Module)}
-     * @param factorySPI used to resolve {@link java.lang.Module} of the implementation.
+     * @param classes used to resolve module for {@linkplain Module#addOpens(String, Module)}
+     * @param factorySPI used to resolve {@link Module} of the implementation.
+     *
+     * @throws JAXBException if ony of a classes package is not open to {@code jakarta.xml.bind} module.
      */
-    static void delegateAddOpensToImplModule(Class<?>[] classes, Class<?> factorySPI) {
-        //stub
+    public static void delegateAddOpensToImplModule(Class<?>[] classes, Class<?> factorySPI) throws JAXBException {
+        final Module implModule = factorySPI.getModule();
+
+        Module jaxbModule = JAXBContext.class.getModule();
+
+        for (Class<?> cls : classes) {
+            Class<?> jaxbClass = cls.isArray() ?
+                    cls.getComponentType() : cls;
+
+            final Module classModule = jaxbClass.getModule();
+            final String packageName = jaxbClass.getPackageName();
+            //no need for unnamed and java.base types
+            if (!classModule.isNamed() || classModule.getName().equals("java.base")) {
+                continue;
+            }
+            //report error if they are not open to jakarta.xml.bind
+            if (!classModule.isOpen(packageName, jaxbModule)) {
+                throw new JAXBException(Messages.format(Messages.JAXB_CLASSES_NOT_OPEN,
+                        packageName, jaxbClass.getName(), classModule.getName()));
+            }
+            //propagate openness to impl module
+            classModule.addOpens(packageName, implModule);
+            if (LOGGER.isLoggable(Level.FINE)) {
+                LOGGER.log(Level.FINE, "Propagating openness of package {0} in {1} to {2}.",
+                        new String[]{ packageName, classModule.getName(), implModule.getName() });
+            }
+        }
     }
 
 }
diff --git a/api/src/main/java/jakarta/xml/bind/PropertyException.java b/api/src/main/java/jakarta/xml/bind/PropertyException.java
index 3a297e3..f559c95 100644
--- a/api/src/main/java/jakarta/xml/bind/PropertyException.java
+++ b/api/src/main/java/jakarta/xml/bind/PropertyException.java
@@ -22,8 +22,10 @@
  * @since 1.6, JAXB 1.0
  */
 public class PropertyException extends JAXBException {
-    
-    /** 
+
+    private static final long serialVersionUID = 3159963351607157477L;
+
+    /**
      * Construct a PropertyException with the specified detail message.  The 
      * errorCode and linkedException will default to null.
      *
diff --git a/api/src/main/java/jakarta/xml/bind/UnmarshalException.java b/api/src/main/java/jakarta/xml/bind/UnmarshalException.java
index 7422013..458a36f 100644
--- a/api/src/main/java/jakarta/xml/bind/UnmarshalException.java
+++ b/api/src/main/java/jakarta/xml/bind/UnmarshalException.java
@@ -29,6 +29,8 @@
  */
 public class UnmarshalException extends JAXBException {
 
+    private static final long serialVersionUID = 6121932693435295453L;
+
     /** 
      * Construct an UnmarshalException with the specified detail message.  The 
      * errorCode and linkedException will default to null.
diff --git a/api/src/main/java/jakarta/xml/bind/ValidationException.java b/api/src/main/java/jakarta/xml/bind/ValidationException.java
index bcf3487..043f714 100644
--- a/api/src/main/java/jakarta/xml/bind/ValidationException.java
+++ b/api/src/main/java/jakarta/xml/bind/ValidationException.java
@@ -26,6 +26,8 @@
  */
 public class ValidationException extends JAXBException {
 
+    private static final long serialVersionUID = 2206436657505193108L;
+
     /** 
      * Construct an ValidationException with the specified detail message.  The 
      * errorCode and linkedException will default to null.
diff --git a/api/src/main/mr-jar/jakarta/xml/bind/ModuleUtil.java b/api/src/main/mr-jar/jakarta/xml/bind/ModuleUtil.java
deleted file mode 100644
index e316871..0000000
--- a/api/src/main/mr-jar/jakarta/xml/bind/ModuleUtil.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (c) 2017, 2021 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Distribution License v. 1.0, which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-package jakarta.xml.bind;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Propagates openness of Jakarta XML Binding annottated classess packages to Jakarta XML Binding impl module.
- *
- * @author Roman Grigoriadi
- */
-class ModuleUtil {
-
-    private static Logger logger = Logger.getLogger("jakarta.xml.bind");
-
-    /**
-     * Resolves classes from context path.
-     * Only one class per package is needed to access its {@link java.lang.Module}
-     */
-    static Class<?>[] getClassesFromContextPath(String contextPath, ClassLoader classLoader) throws JAXBException {
-        List<Class<?>> classes = new ArrayList<>();
-        if (contextPath == null || contextPath.isEmpty()){
-          return classes.toArray(new Class<?>[]{});
-        }
-
-        String [] tokens = contextPath.split(":");
-        for (String pkg : tokens){
-
-           // look for ObjectFactory and load it
-           final Class<?> o;
-           try {
-               o = classLoader.loadClass(pkg+".ObjectFactory");
-               classes.add(o);
-               continue;
-           } catch (ClassNotFoundException e) {
-               // not necessarily an error
-           }
-
-           // look for jaxb.index and load the list of classes
-           try {
-               final Class<?> firstByJaxbIndex = findFirstByJaxbIndex(pkg, classLoader);
-               if (firstByJaxbIndex != null) {
-                   classes.add(firstByJaxbIndex);
-               }
-           } catch (IOException e) {
-               throw new JAXBException(e);
-           }
-        }
-
-        if (logger.isLoggable(Level.FINE)) {
-            logger.log(Level.FINE, "Resolved classes from context path: {0}", classes);
-        }
-        return classes.toArray(new Class<?>[]{});
-    }
-
-    /**
-     * Find first class in package by {@code jaxb.index} file.
-     */
-    static Class<?> findFirstByJaxbIndex(String pkg, ClassLoader classLoader) throws IOException, JAXBException {
-        final String resource = pkg.replace('.', '/') + "/jaxb.index";
-        final InputStream resourceAsStream = classLoader.getResourceAsStream(resource);
-
-        if (resourceAsStream == null) {
-            return null;
-        }
-
-        BufferedReader in =
-                new BufferedReader(new InputStreamReader(resourceAsStream, "UTF-8"));
-        try {
-            String className = in.readLine();
-            while (className != null) {
-                className = className.trim();
-                if (className.startsWith("#") || (className.length() == 0)) {
-                    className = in.readLine();
-                    continue;
-                }
-
-                try {
-                    return classLoader.loadClass(pkg + '.' + className);
-                } catch (ClassNotFoundException e) {
-                    throw new JAXBException(Messages.format(Messages.ERROR_LOAD_CLASS, className, pkg), e);
-                }
-
-            }
-        } finally {
-            in.close();
-        }
-        return null;
-    }
-
-    /**
-     * Implementation may be defined in other module than {@code jakarta.xml.bind}. In that case openness
-     * {@linkplain Module#isOpen open} of classes should be delegated to implementation module.
-     *
-     * @param classes used to resolve module for {@linkplain Module#addOpens(String, Module)}
-     * @param factorySPI used to resolve {@link Module} of the implementation.
-     *
-     * @throws JAXBException if ony of a classes package is not open to {@code jakarta.xml.bind} module.
-     */
-    public static void delegateAddOpensToImplModule(Class<?>[] classes, Class<?> factorySPI) throws JAXBException {
-        final Module implModule = factorySPI.getModule();
-
-        Module jaxbModule = JAXBContext.class.getModule();
-
-        for (Class<?> cls : classes) {
-            Class<?> jaxbClass = cls.isArray() ?
-                cls.getComponentType() : cls;
-
-            final Module classModule = jaxbClass.getModule();
-            final String packageName = jaxbClass.getPackageName();
-            //no need for unnamed and java.base types
-            if (!classModule.isNamed() || classModule.getName().equals("java.base")) {
-                continue;
-            }
-            //report error if they are not open to jakarta.xml.bind
-            if (!classModule.isOpen(packageName, jaxbModule)) {
-                throw new JAXBException(Messages.format(Messages.JAXB_CLASSES_NOT_OPEN,
-                                                        packageName, jaxbClass.getName(), classModule.getName()));
-            }
-            //propagate openness to impl module
-            classModule.addOpens(packageName, implModule);
-            if (logger.isLoggable(Level.FINE)) {
-                logger.log(Level.FINE, "Propagating openness of package {0} in {1} to {2}.",
-                           new String[]{ packageName, classModule.getName(), implModule.getName() });
-            }
-        }
-    }
-
-}
diff --git a/pom.xml b/pom.xml
index d6d893c..75f1e8d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -78,6 +78,8 @@
         <spotbugs.threshold>Low</spotbugs.threshold>
         <spotbugs.version>4.3.0</spotbugs.version>
 
+        <maven.compiler.release>11</maven.compiler.release>
+
         <release.spec.feedback>jaxb-dev@eclipse.org</release.spec.feedback>
         <release.spec.date>Jul 2017</release.spec.date>
         <api.package>jakarta.xml.bind</api.package>