remove deprecated apis

Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
diff --git a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/VarArgsTest.java b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/VarArgsTest.java
index 53a9ba7..2c24cae 100644
--- a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/VarArgsTest.java
+++ b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/VarArgsTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2022 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
@@ -88,12 +88,6 @@
             main.body().directStatement("new Test().foo(new String(\"Param1\"),new Integer(5),null,new String(\"Param3\"),new String(\"Param4\"));" );//new String("Param1"))"");//                "new Integer(5),+//                "null," +//                "new String("first")," +//                " new String("Second"))");
             
             cm.build(new SingleStreamCodeWriter(System.out));
-        } catch (JClassAlreadyExistsException e) {
-            
-            e.printStackTrace();
-        } catch (IOException e) {
-            
-            e.printStackTrace();
         } catch (Exception e) {
             e.printStackTrace();
         }
diff --git a/jaxb-ri/external/relaxng-datatype/src/main/java/com/sun/tools/rngdatatype/helpers/DatatypeLibraryLoader.java b/jaxb-ri/external/relaxng-datatype/src/main/java/com/sun/tools/rngdatatype/helpers/DatatypeLibraryLoader.java
index 249a9ed..3f19eb2 100644
--- a/jaxb-ri/external/relaxng-datatype/src/main/java/com/sun/tools/rngdatatype/helpers/DatatypeLibraryLoader.java
+++ b/jaxb-ri/external/relaxng-datatype/src/main/java/com/sun/tools/rngdatatype/helpers/DatatypeLibraryLoader.java
@@ -189,18 +189,15 @@
 	      while (classNames.hasMoreElements()) {
 		String className = (String)classNames.nextElement();
 		try {
-		  Class cls = loader.loadClass(className);
-		  Object obj = cls.newInstance();
+		  Class<?> cls = loader.loadClass(className);
+		  Object obj = cls.getConstructor().newInstance();
 		  if (serviceClass.isInstance(obj)) {
 		    providers.addElement(obj);
 		    return true;
 		  }
 		}
-		catch (ClassNotFoundException e) { }
-		catch (InstantiationException e) { }
-		catch (IllegalAccessException e) { }
-		catch (LinkageError e) { }
-	      }
+		catch (ReflectiveOperationException | LinkageError e) { }
+		  }
 	      classNames = null;
 	    }
 	  }
diff --git a/jaxb-ri/external/rngom/src/main/java/com/sun/tools/rngom/parse/xml/SchemaParser.java b/jaxb-ri/external/rngom/src/main/java/com/sun/tools/rngom/parse/xml/SchemaParser.java
index 8ebef2e..6a34282 100644
--- a/jaxb-ri/external/rngom/src/main/java/com/sun/tools/rngom/parse/xml/SchemaParser.java
+++ b/jaxb-ri/external/rngom/src/main/java/com/sun/tools/rngom/parse/xml/SchemaParser.java
@@ -1746,9 +1746,7 @@
         if (schemaBuilder.usesComments()) {
             try {
                 xr.setProperty("http://xml.org/sax/properties/lexical-handler", new LexicalHandlerImpl());
-            } catch (SAXNotRecognizedException e) {
-                warning("no_comment_support", xr.getClass().getName());
-            } catch (SAXNotSupportedException e) {
+            } catch (SAXNotRecognizedException | SAXNotSupportedException e) {
                 warning("no_comment_support", xr.getClass().getName());
             }
         }
diff --git a/jaxb-ri/external/rngom/src/main/java/com/sun/tools/rngom/xml/sax/JAXPXMLReaderCreator.java b/jaxb-ri/external/rngom/src/main/java/com/sun/tools/rngom/xml/sax/JAXPXMLReaderCreator.java
index c749065..7f1564d 100644
--- a/jaxb-ri/external/rngom/src/main/java/com/sun/tools/rngom/xml/sax/JAXPXMLReaderCreator.java
+++ b/jaxb-ri/external/rngom/src/main/java/com/sun/tools/rngom/xml/sax/JAXPXMLReaderCreator.java
@@ -56,11 +56,7 @@
         try {
             spf.setNamespaceAware(true);
             spf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
-        } catch (ParserConfigurationException ex) {
-            Logger.getLogger(JAXPXMLReaderCreator.class.getName()).log(Level.SEVERE, null, ex);
-        } catch (SAXNotRecognizedException ex) {
-            Logger.getLogger(JAXPXMLReaderCreator.class.getName()).log(Level.SEVERE, null, ex);
-        } catch (SAXNotSupportedException ex) {
+        } catch (ParserConfigurationException | SAXNotSupportedException | SAXNotRecognizedException ex) {
             Logger.getLogger(JAXPXMLReaderCreator.class.getName()).log(Level.SEVERE, null, ex);
         }
     }
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/api/Bridge.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/api/Bridge.java
index 9416d3a..d15d3f2 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/api/Bridge.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/api/Bridge.java
@@ -12,7 +12,6 @@
 
 import com.sun.istack.NotNull;
 import com.sun.istack.Nullable;
-import org.glassfish.jaxb.runtime.v2.runtime.BridgeContextImpl;
 import org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl;
 import jakarta.xml.bind.JAXBException;
 import jakarta.xml.bind.Marshaller;
@@ -81,10 +80,6 @@
         context.marshallerPool.recycle(m);
     }
 
-    public final void marshal(@NotNull BridgeContext context,T object,XMLStreamWriter output) throws JAXBException {
-        marshal( ((BridgeContextImpl)context).marshaller, object, output );
-    }
-
     public abstract void marshal(@NotNull Marshaller m,T object,XMLStreamWriter output) throws JAXBException;
 
 
@@ -115,10 +110,6 @@
         context.marshallerPool.recycle(m);
     }
 
-    public final void marshal(@NotNull BridgeContext context,T object,OutputStream output, NamespaceContext nsContext) throws JAXBException {
-        marshal( ((BridgeContextImpl)context).marshaller, object, output, nsContext );
-    }
-
     public abstract void marshal(@NotNull Marshaller m,T object,OutputStream output, NamespaceContext nsContext) throws JAXBException;
 
 
@@ -128,10 +119,6 @@
         context.marshallerPool.recycle(m);
     }
 
-    public final void marshal(@NotNull BridgeContext context,T object,Node output) throws JAXBException {
-        marshal( ((BridgeContextImpl)context).marshaller, object, output );
-    }
-
     public abstract void marshal(@NotNull Marshaller m,T object,Node output) throws JAXBException;
 
 
@@ -151,9 +138,7 @@
         m.setAttachmentMarshaller(null);
         context.marshallerPool.recycle(m);
     }
-    public final void marshal(@NotNull BridgeContext context,T object, ContentHandler contentHandler) throws JAXBException {
-        marshal( ((BridgeContextImpl)context).marshaller, object, contentHandler );
-    }
+
     public abstract void marshal(@NotNull Marshaller m,T object, ContentHandler contentHandler) throws JAXBException;
 
     /**
@@ -164,9 +149,7 @@
         marshal(m,object,result);
         context.marshallerPool.recycle(m);
     }
-    public final void marshal(@NotNull BridgeContext context,T object, Result result) throws JAXBException {
-        marshal( ((BridgeContextImpl)context).marshaller, object, result );
-    }
+
     public abstract void marshal(@NotNull Marshaller m,T object, Result result) throws JAXBException;
 
 
@@ -204,9 +187,7 @@
         u.setAttachmentUnmarshaller(au);
         return exit(unmarshal(u,in),u);
     }
-    public final @NotNull T unmarshal(@NotNull BridgeContext context, @NotNull XMLStreamReader in) throws JAXBException {
-        return unmarshal( ((BridgeContextImpl)context).unmarshaller, in );
-    }
+
     public abstract @NotNull T unmarshal(@NotNull Unmarshaller u, @NotNull XMLStreamReader in) throws JAXBException;
 
     /**
@@ -236,9 +217,7 @@
         u.setAttachmentUnmarshaller(au);
         return exit(unmarshal(u,in),u);
     }
-    public final @NotNull T unmarshal(@NotNull BridgeContext context, @NotNull Source in) throws JAXBException {
-        return unmarshal( ((BridgeContextImpl)context).unmarshaller, in );
-    }
+
     public abstract @NotNull T unmarshal(@NotNull Unmarshaller u, @NotNull Source in) throws JAXBException;
 
     /**
@@ -261,9 +240,7 @@
         Unmarshaller u = context.unmarshallerPool.take();
         return exit(unmarshal(u,in),u);
     }
-    public final @NotNull T unmarshal(@NotNull BridgeContext context, @NotNull InputStream in) throws JAXBException {
-        return unmarshal( ((BridgeContextImpl)context).unmarshaller, in );
-    }
+
     public abstract @NotNull T unmarshal(@NotNull Unmarshaller u, @NotNull InputStream in) throws JAXBException;
 
     /**
@@ -291,9 +268,7 @@
         u.setAttachmentUnmarshaller(au);
         return exit(unmarshal(u,n),u);
     }
-    public final @NotNull T unmarshal(@NotNull BridgeContext context, @NotNull Node n) throws JAXBException {
-        return unmarshal( ((BridgeContextImpl)context).unmarshaller, n );
-    }
+
     public abstract @NotNull T unmarshal(@NotNull Unmarshaller context, @NotNull Node n) throws JAXBException;
 
     /**
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/api/BridgeContext.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/api/BridgeContext.java
deleted file mode 100644
index e673a74..0000000
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/api/BridgeContext.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 1997, 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 org.glassfish.jaxb.runtime.api;
-
-import jakarta.xml.bind.ValidationEventHandler;
-import jakarta.xml.bind.attachment.AttachmentMarshaller;
-import jakarta.xml.bind.attachment.AttachmentUnmarshaller;
-
-/**
- * Holds thread specific state information for {@link Bridge}s,
- * to make {@link Bridge} thread-safe.
- *
- * <p>
- * This object cannot be used concurrently; two threads cannot
- * use the same object with {@link Bridge}s at the same time, nor
- * a thread can use a {@link BridgeContext} with one {@link Bridge} while
- * the same context is in use by another {@link Bridge}.
- *
- * <p>
- * {@link BridgeContext} is relatively a heavy-weight object, and
- * therefore it is expected to be cached by the JAX-RPC RI.
- *
- * <p>
- * <b>Subject to change without notice</b>.
- *
- * @author Kohsuke Kawaguchi
- * @since 2.0 EA1
- * @see Bridge
- * @deprecated
- *      The caller no longer needs to use this, as {@link Bridge} has
- *      methods that can work without {@link BridgeContext}.
- */
-@Deprecated
-public abstract class BridgeContext {
-    protected BridgeContext() {}
-    
-    /**
-     * Registers the error handler that receives unmarshalling/marshalling errors.
-     *
-     * @param handler
-     *      can be null, in which case all errors will be considered fatal.
-     *
-     * @since 2.0 EA1
-     */
-    public abstract void setErrorHandler(ValidationEventHandler handler);
-
-    /**
-     * Sets the {@link AttachmentMarshaller}.
-     *
-     * @since 2.0 EA1
-     */
-    public abstract void setAttachmentMarshaller(AttachmentMarshaller m);
-
-    /**
-     * Sets the {@link AttachmentUnmarshaller}.
-     *
-     * @since 2.0 EA1
-     */
-    public abstract void setAttachmentUnmarshaller(AttachmentUnmarshaller m);
-
-    /**
-     * Gets the last {@link AttachmentMarshaller} set through
-     * {@link AttachmentMarshaller}.
-     *
-     * @since 2.0 EA2
-     */
-    public abstract AttachmentMarshaller getAttachmentMarshaller();
-
-    /**
-     * Gets the last {@link AttachmentUnmarshaller} set through
-     * {@link AttachmentUnmarshaller}.
-     *
-     * @since 2.0 EA2
-     */
-    public abstract AttachmentUnmarshaller getAttachmentUnmarshaller();
-}
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/api/JAXBRIContext.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/api/JAXBRIContext.java
index eb55999..66bcfac 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/api/JAXBRIContext.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/api/JAXBRIContext.java
@@ -133,18 +133,6 @@
     }
 
     /**
-     * @deprecated
-     *      Compatibility with older versions.
-     */
-    @Deprecated
-    public static JAXBRIContext newInstance(@NotNull Class[] classes,
-        @Nullable Collection<TypeReference> typeRefs,
-        @Nullable String defaultNamespaceRemap, boolean c14nSupport ) throws JAXBException {
-        return newInstance(classes,typeRefs, Collections.emptyMap(),
-                defaultNamespaceRemap,c14nSupport,null);
-    }
-
-    /**
      * Returns true if this context includes a class
      * that has {@link XmlAttachmentRef}.
      *
@@ -182,16 +170,6 @@
     public abstract Bridge createBridge(@NotNull TypeReference ref);
 
     /**
-     * Creates a new {@link BridgeContext} instance.
-     *
-     * @return
-     *      always a valid non-null instance.
-     *
-     * @since 2.0 EA1
-     */
-    public abstract @NotNull BridgeContext createBridgeContext();
-
-    /**
      * Gets a {@link RawAccessor} for the specified element property of the specified wrapper bean class.
      *
      * <p>
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/model/impl/RuntimeBuiltinLeafInfoImpl.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/model/impl/RuntimeBuiltinLeafInfoImpl.java
index 33a3e78..d06c6f8 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/model/impl/RuntimeBuiltinLeafInfoImpl.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/model/impl/RuntimeBuiltinLeafInfoImpl.java
@@ -233,6 +233,7 @@
         secondaryList.add(
             new StringImpl<Character>(Character.class, createXS("unsignedShort")) {
                 @Override
+                @SuppressWarnings({"deprecation"})
                 public Character parse(CharSequence text) {
                     // TODO.checkSpec("default mapping for char is not defined yet");
                     return (char) DatatypeConverterImpl._parseInt(text);
@@ -245,10 +246,12 @@
         secondaryList.add(
             new StringImpl<Calendar>(Calendar.class, DatatypeConstants.DATETIME) {
                 @Override
+                @SuppressWarnings({"deprecation"})
                 public Calendar parse(CharSequence text) {
                     return DatatypeConverterImpl._parseDateTime(text.toString());
                 }
                 @Override
+                @SuppressWarnings({"deprecation"})
                 public String print(Calendar v) {
                     return DatatypeConverterImpl._printDateTime(v);
                 }
@@ -256,10 +259,12 @@
         secondaryList.add(
             new StringImpl<GregorianCalendar>(GregorianCalendar.class, DatatypeConstants.DATETIME) {
                 @Override
+                @SuppressWarnings({"deprecation"})
                 public GregorianCalendar parse(CharSequence text) {
                     return DatatypeConverterImpl._parseDateTime(text.toString());
                 }
                 @Override
+                @SuppressWarnings({"deprecation"})
                 public String print(GregorianCalendar v) {
                     return DatatypeConverterImpl._printDateTime(v);
                 }
@@ -267,10 +272,12 @@
         secondaryList.add(
             new StringImpl<Date>(Date.class, DatatypeConstants.DATETIME) {
                 @Override
+                @SuppressWarnings({"deprecation"})
                 public Date parse(CharSequence text) {
                     return DatatypeConverterImpl._parseDateTime(text.toString()).getTime();
                 }
                 @Override
+                @SuppressWarnings({"deprecation"})
                 public String print(Date v) {
                     XMLSerializer xs = XMLSerializer.getInstance();
                     QName type = xs.getSchemaType();
@@ -578,6 +585,7 @@
                 }
 
                 @Override
+                @SuppressWarnings({"deprecation"})
                 public XMLGregorianCalendar parse(CharSequence lexical) throws SAXException {
                     try {
                         return DatatypeConverterImpl.getDatatypeFactory()
@@ -675,6 +683,7 @@
                 createXS("boolean")
                 ) {
                 @Override
+                @SuppressWarnings({"deprecation"})
                 public Boolean parse(CharSequence text) {
                     return DatatypeConverterImpl._parseBoolean(text);
                 }
@@ -706,11 +715,13 @@
                 createXS("byte")
                 ) {
                 @Override
+                @SuppressWarnings({"deprecation"})
                 public Byte parse(CharSequence text) {
                     return DatatypeConverterImpl._parseByte(text);
                 }
 
                 @Override
+                @SuppressWarnings({"deprecation"})
                 public String print(Byte v) {
                     return DatatypeConverterImpl._printByte(v);
                 }
@@ -720,11 +731,13 @@
                 createXS("unsignedByte")
                 ) {
                 @Override
+                @SuppressWarnings({"deprecation"})
                 public Short parse(CharSequence text) {
                     return DatatypeConverterImpl._parseShort(text);
                 }
 
                 @Override
+                @SuppressWarnings({"deprecation"})
                 public String print(Short v) {
                     return DatatypeConverterImpl._printShort(v);
                 }
@@ -734,11 +747,13 @@
                 createXS("unsignedShort")
                 ) {
                 @Override
+                @SuppressWarnings({"deprecation"})
                 public Integer parse(CharSequence text) {
                     return DatatypeConverterImpl._parseInt(text);
                 }
 
                 @Override
+                @SuppressWarnings({"deprecation"})
                 public String print(Integer v) {
                     return DatatypeConverterImpl._printInt(v);
                 }
@@ -749,11 +764,13 @@
                 createXS("unsignedInt")
                 ) {
                 @Override
+                @SuppressWarnings({"deprecation"})
                 public Long parse(CharSequence text) {
                     return DatatypeConverterImpl._parseLong(text);
                 }
 
                 @Override
+                @SuppressWarnings({"deprecation"})
                 public String print(Long v) {
                     return DatatypeConverterImpl._printLong(v);
                 }
@@ -763,11 +780,13 @@
                 createXS("float")
                 ) {
                 @Override
+                @SuppressWarnings({"deprecation"})
                 public Float parse(CharSequence text) {
                     return DatatypeConverterImpl._parseFloat(text.toString());
                 }
 
                 @Override
+                @SuppressWarnings({"deprecation"})
                 public String print(Float v) {
                     return DatatypeConverterImpl._printFloat(v);
                 }
@@ -777,11 +796,13 @@
                 createXS("double")
                 ) {
                 @Override
+                @SuppressWarnings({"deprecation"})
                 public Double parse(CharSequence text) {
                     return DatatypeConverterImpl._parseDouble(text);
                 }
 
                 @Override
+                @SuppressWarnings({"deprecation"})
                 public String print(Double v) {
                     return DatatypeConverterImpl._printDouble(v);
                 }
@@ -796,11 +817,13 @@
                 createXS("unsignedLong")
                 ) {
                 @Override
+                @SuppressWarnings({"deprecation"})
                 public BigInteger parse(CharSequence text) {
                     return DatatypeConverterImpl._parseInteger(text);
                 }
 
                 @Override
+                @SuppressWarnings({"deprecation"})
                 public String print(BigInteger v) {
                     return DatatypeConverterImpl._printInteger(v);
                 }
@@ -810,11 +833,13 @@
                         createXS("decimal")
                 ) {
                     @Override
+                    @SuppressWarnings({"deprecation"})
                     public BigDecimal parse(CharSequence text) {
                         return DatatypeConverterImpl._parseDecimal(text.toString());
                     }
 
                     @Override
+                    @SuppressWarnings({"deprecation"})
                     public String print(BigDecimal v) {
                         return DatatypeConverterImpl._printDecimal(v);
                     }
@@ -825,6 +850,7 @@
                 createXS("QName")
                 ) {
                 @Override
+                @SuppressWarnings({"deprecation"})
                 public QName parse(CharSequence text) throws SAXException {
                     try {
                         return DatatypeConverterImpl._parseQName(text.toString(),UnmarshallingContext.getInstance());
@@ -835,6 +861,7 @@
                 }
 
                 @Override
+                @SuppressWarnings({"deprecation"})
                 public String print(QName v) {
                     return DatatypeConverterImpl._printQName(v,XMLSerializer.getInstance().getNamespaceContext());
                 }
@@ -876,6 +903,7 @@
                     }
 
                     @Override
+                    @SuppressWarnings({"deprecation"})
                     public Duration parse(CharSequence lexical) {
                         TODO.checkSpec("JSR222 Issue #42");
                         return DatatypeConverterImpl.getDatatypeFactory().newDuration(lexical.toString());
@@ -913,6 +941,7 @@
         builtinBeanInfos = Collections.unmodifiableList(l);
     }
 
+    @SuppressWarnings({"deprecation"})
     private static byte[] decodeBase64(CharSequence text) {
         if (text instanceof Base64Data) {
             Base64Data base64Data = (Base64Data) text;
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/BridgeContextImpl.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/BridgeContextImpl.java
deleted file mode 100644
index 57d2aa3..0000000
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/BridgeContextImpl.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 1997, 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 org.glassfish.jaxb.runtime.v2.runtime;
-
-import org.glassfish.jaxb.runtime.api.BridgeContext;
-import org.glassfish.jaxb.runtime.v2.runtime.unmarshaller.UnmarshallerImpl;
-import jakarta.xml.bind.JAXBException;
-import jakarta.xml.bind.ValidationEventHandler;
-import jakarta.xml.bind.attachment.AttachmentMarshaller;
-import jakarta.xml.bind.attachment.AttachmentUnmarshaller;
-
-/**
- * {@link BridgeContext} implementation.
- *
- * @author Kohsuke Kawaguchi
- */
-public final class BridgeContextImpl extends BridgeContext {
-
-    public final UnmarshallerImpl unmarshaller;
-    public final MarshallerImpl marshaller;
-
-    BridgeContextImpl(JAXBContextImpl context) {
-        unmarshaller = context.createUnmarshaller();
-        marshaller = context.createMarshaller();
-    }
-
-    @Override
-    public void setErrorHandler(ValidationEventHandler handler) {
-        try {
-            unmarshaller.setEventHandler(handler);
-            marshaller.setEventHandler(handler);
-        } catch (JAXBException e) {
-            // impossible
-            throw new Error(e);
-        }
-    }
-
-    @Override
-    public void setAttachmentMarshaller(AttachmentMarshaller m) {
-        marshaller.setAttachmentMarshaller(m);
-    }
-
-    @Override
-    public void setAttachmentUnmarshaller(AttachmentUnmarshaller u) {
-        unmarshaller.setAttachmentUnmarshaller(u);
-    }
-
-    @Override
-    public AttachmentMarshaller getAttachmentMarshaller() {
-        return marshaller.getAttachmentMarshaller();
-    }
-
-    @Override
-    public AttachmentUnmarshaller getAttachmentUnmarshaller() {
-        return unmarshaller.getAttachmentUnmarshaller();
-    }
-}
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/ContentHandlerAdaptor.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/ContentHandlerAdaptor.java
index 15267bf..8869e30 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/ContentHandlerAdaptor.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/ContentHandlerAdaptor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2022 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
@@ -108,9 +108,7 @@
             }
             prefixMap.clear();
             serializer.endAttributes();
-        } catch (IOException e) {
-            throw new SAXException2(e);
-        } catch (XMLStreamException e) {
+        } catch (IOException | XMLStreamException e) {
             throw new SAXException2(e);
         }
     }
@@ -126,9 +124,7 @@
         try {
             flushText();
             serializer.endElement();
-        } catch (IOException e) {
-            throw new SAXException2(e);
-        } catch (XMLStreamException e) {
+        } catch (IOException | XMLStreamException e) {
             throw new SAXException2(e);
         }
     }
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/JAXBContextImpl.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/JAXBContextImpl.java
index c8893d1..03bb093 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/JAXBContextImpl.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/JAXBContextImpl.java
@@ -886,11 +886,6 @@
         return bridges.get(ref);
     }
 
-    public @NotNull@Override
- BridgeContext createBridgeContext() {
-        return new BridgeContextImpl(this);
-    }
-
     @Override
     public RawAccessor getElementPropertyAccessor(Class wrapperBean, String nsUri, String localName) throws JAXBException {
         JaxBeanInfo bi = getBeanInfo(wrapperBean,true);
@@ -966,11 +961,7 @@
                 if(ap.attName.equals(WellKnownNamespace.XML_MIME_URI,"contentType"))
                     try {
                         return (String)ap.xacc.print(o);
-                    } catch (AccessorException e) {
-                        return null;
-                    } catch (SAXException e) {
-                        return null;
-                    } catch (ClassCastException e) {
+                    } catch (AccessorException | ClassCastException | SAXException e) {
                         return null;
                     }
             }
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/JaxBeanInfo.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/JaxBeanInfo.java
index ea5c81f..d63bc39 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/JaxBeanInfo.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/JaxBeanInfo.java
@@ -531,9 +531,7 @@
     private void invokeUnmarshallCallback(Method m, Object child, UnmarshallerImpl unm, Object parent) throws SAXException {
         try {
             m.invoke(child,unm,parent);
-        } catch (IllegalAccessException e) {
-            UnmarshallingContext.getInstance().handleError(e, false);
-        } catch (InvocationTargetException e) {
+        } catch (IllegalAccessException | InvocationTargetException e) {
             UnmarshallingContext.getInstance().handleError(e, false);
         }
     }
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/MarshallerImpl.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/MarshallerImpl.java
index e892783..a27a401 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/MarshallerImpl.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/MarshallerImpl.java
@@ -218,11 +218,7 @@
                 }
                 serializer.endElement();
                 postwrite();
-            } catch( SAXException e ) {
-                throw new MarshalException(e);
-            } catch (IOException e) {
-                throw new MarshalException(e);
-            } catch (XMLStreamException e) {
+            } catch( SAXException | XMLStreamException | IOException e ) {
                 throw new MarshalException(e);
             } finally {
                 serializer.close();
@@ -268,11 +264,7 @@
                 prewrite(out,isFragment(),postInitAction);
                 serializer.childAsRoot(obj);
                 postwrite();
-            } catch( SAXException e ) {
-                throw new MarshalException(e);
-            } catch (IOException e) {
-                throw new MarshalException(e);
-            } catch (XMLStreamException e) {
+            } catch( SAXException | XMLStreamException | IOException e ) {
                 throw new MarshalException(e);
             } finally {
                 serializer.close();
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/XMLSerializer.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/XMLSerializer.java
index cd22dba..36a31dd 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/XMLSerializer.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/XMLSerializer.java
@@ -397,9 +397,7 @@
 
         try {
             out.attribute(prefix,local,value);
-        } catch (IOException e) {
-            throw new SAXException2(e);
-        } catch (XMLStreamException e) {
+        } catch (IOException | XMLStreamException e) {
             throw new SAXException2(e);
         }
     }
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/output/UTF8XmlOutput.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/output/UTF8XmlOutput.java
index 31e2fb3..b175393 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/output/UTF8XmlOutput.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/output/UTF8XmlOutput.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2022 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
@@ -329,6 +329,7 @@
      * Being defined on this class allows this method to access the buffer directly,
      * which translates to a better performance.
      */
+    @SuppressWarnings({"deprecation"})
     public void text(byte[] data, int dataLen) throws IOException {
         closeStartTag();
 
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/property/SingleReferenceNodeProperty.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/property/SingleReferenceNodeProperty.java
index 2db3912..a8eaf2e 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/property/SingleReferenceNodeProperty.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/property/SingleReferenceNodeProperty.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2022 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
@@ -129,11 +129,7 @@
                         if(value!=null) {
                             try {
                                 value = ebi.createInstanceFromValue(value);
-                            } catch (IllegalAccessException e) {
-                                throw new AccessorException(e);
-                            } catch (InvocationTargetException e) {
-                                throw new AccessorException(e);
-                            } catch (InstantiationException e) {
+                            } catch (ReflectiveOperationException e) {
                                 throw new AccessorException(e);
                             }
                         }
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/TransducedAccessor.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/TransducedAccessor.java
index dac0472..211645e 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/TransducedAccessor.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/TransducedAccessor.java
@@ -283,9 +283,7 @@
             TargetT t;
             try {
                 t = (TargetT)callable.call();
-            } catch (SAXException e) {// from callable.call
-                throw e;
-            } catch (RuntimeException e) {// from callable.call
+            } catch (SAXException | RuntimeException e) {// from callable.call
                 throw e;
             } catch (Exception e) {// from callable.call
                 throw new SAXException2(e);
@@ -307,9 +305,7 @@
                             }
                         } catch (AccessorException e) {
                             context.handleError(e);
-                        } catch (SAXException e) {// from callable.call
-                            throw e;
-                        } catch (RuntimeException e) {// from callable.call
+                        } catch (SAXException | RuntimeException e) {// from callable.call
                             throw e;
                         } catch (Exception e) {// from callable.call
                             throw new SAXException2(e);
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/Injector.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/Injector.java
index b031287..20eb961 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/Injector.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/Injector.java
@@ -288,7 +288,7 @@
                         } else {
                             c = (Class) defineClass.invoke(U, className.replace('/', '.'), image, 0, image.length, parent, Injector.class.getProtectionDomain());
                         }
-                    } catch (IllegalAccessException  e) {
+                    } catch (IllegalAccessException | LinkageError | SecurityException e) {
                         logger.log(Level.FINE, "Unable to inject " + className, e);
                         return null;
                     } catch (InvocationTargetException e) {
@@ -299,12 +299,6 @@
                             logger.log(Level.FINE, "Unable to inject " + className, t);
                         }
                         return null;
-                    } catch (SecurityException e) {
-                        logger.log(Level.FINE, "Unable to inject " + className, e);
-                        return null;
-                    } catch (LinkageError e) {
-                        logger.log(Level.FINE, "Unable to inject " + className, e);
-                        return null;
                     }
 
                     w.lock();
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_field_Boolean.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_field_Boolean.java
index 5f028ce..65c81d3 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_field_Boolean.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_field_Boolean.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2022 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
@@ -24,6 +24,7 @@
  *
  * @see TransducedAccessor#get
  */
+@SuppressWarnings({"deprecation"})
 public final class TransducedAccessor_field_Boolean extends DefaultTransducedAccessor {
     @Override
     public String print(Object o) {
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_field_Byte.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_field_Byte.java
index 35f0efa..8ba5259 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_field_Byte.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_field_Byte.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2022 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
@@ -24,6 +24,7 @@
  *
  * @see TransducedAccessor#get
  */
+@SuppressWarnings({"deprecation"})
 public final class TransducedAccessor_field_Byte extends DefaultTransducedAccessor {
     @Override
     public String print(Object o) {
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_field_Double.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_field_Double.java
index 486b420..6d71eee 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_field_Double.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_field_Double.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2022 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
@@ -26,6 +26,7 @@
  *
  * @see TransducedAccessor#get
  */
+@SuppressWarnings({"deprecation"})
 public final class TransducedAccessor_field_Double extends DefaultTransducedAccessor {
     @Override
     public String print(Object o) {
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_field_Float.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_field_Float.java
index 9b66185..d8ec4ae 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_field_Float.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_field_Float.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2022 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
@@ -26,6 +26,7 @@
  *
  * @see TransducedAccessor#get
  */
+@SuppressWarnings({"deprecation"})
 public final class TransducedAccessor_field_Float extends DefaultTransducedAccessor {
     @Override
     public String print(Object o) {
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_field_Integer.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_field_Integer.java
index e1cb409..3eab3b9 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_field_Integer.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_field_Integer.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2022 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
@@ -31,6 +31,7 @@
  *
  * @see TransducedAccessor#get
  */
+@SuppressWarnings({"deprecation"})
 public final class TransducedAccessor_field_Integer extends DefaultTransducedAccessor {
     @Override
     public String print(Object o) {
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_field_Long.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_field_Long.java
index 9b66831..39ab021 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_field_Long.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_field_Long.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2022 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
@@ -26,6 +26,7 @@
  *
  * @see TransducedAccessor#get
  */
+@SuppressWarnings({"deprecation"})
 public final class TransducedAccessor_field_Long extends DefaultTransducedAccessor {
     @Override
     public String print(Object o) {
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_field_Short.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_field_Short.java
index da1d747..e9112af 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_field_Short.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_field_Short.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2022 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
@@ -26,6 +26,7 @@
  *
  * @see TransducedAccessor#get
  */
+@SuppressWarnings({"deprecation"})
 public final class TransducedAccessor_field_Short extends DefaultTransducedAccessor {
     @Override
     public String print(Object o) {
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_method_Boolean.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_method_Boolean.java
index 00418f3..35a36ec 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_method_Boolean.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_method_Boolean.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2022 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
@@ -26,6 +26,7 @@
  *
  * @see TransducedAccessor#get
  */
+@SuppressWarnings({"deprecation"})
 public final class TransducedAccessor_method_Boolean extends DefaultTransducedAccessor {
     @Override
     public String print(Object o) {
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_method_Byte.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_method_Byte.java
index c6088da..d97bc9c 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_method_Byte.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_method_Byte.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2022 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
@@ -24,6 +24,7 @@
  *
  * @see TransducedAccessor#get
  */
+@SuppressWarnings({"deprecation"})
 public final class TransducedAccessor_method_Byte extends DefaultTransducedAccessor {
     @Override
     public String print(Object o) {
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_method_Double.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_method_Double.java
index cd0e2b1..d06626f 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_method_Double.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_method_Double.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2022 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
@@ -20,12 +20,13 @@
  *     Auto-generated, do not edit.
  * </b></p>
  * <p>
- *     All the TransducedAccessor_field are generated from <code>TransducedAccessor_field_B y t e</code>
+ *     All the TransducedAccessor_field are generated from <code>TransducedAccessor_field_Byte</code>
  * </p>
  * @author Kohsuke Kawaguchi
  *
  * @see TransducedAccessor#get
  */
+@SuppressWarnings({"deprecation"})
 public final class TransducedAccessor_method_Double extends DefaultTransducedAccessor {
     @Override
     public String print(Object o) {
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_method_Float.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_method_Float.java
index 4d55105..cfdc60b 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_method_Float.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_method_Float.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2022 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
@@ -26,6 +26,7 @@
  *
  * @see TransducedAccessor#get
  */
+@SuppressWarnings({"deprecation"})
 public final class TransducedAccessor_method_Float extends DefaultTransducedAccessor {
     @Override
     public String print(Object o) {
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_method_Integer.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_method_Integer.java
index 2495615..30cfbc0 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_method_Integer.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_method_Integer.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2022 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
@@ -31,6 +31,7 @@
  *
  * @see TransducedAccessor#get
  */
+@SuppressWarnings({"deprecation"})
 public final class TransducedAccessor_method_Integer extends DefaultTransducedAccessor {
     @Override
     public String print(Object o) {
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_method_Long.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_method_Long.java
index 4bba213..8fef389 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_method_Long.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_method_Long.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2022 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
@@ -26,6 +26,7 @@
  *
  * @see TransducedAccessor#get
  */
+@SuppressWarnings({"deprecation"})
 public final class TransducedAccessor_method_Long extends DefaultTransducedAccessor {
     @Override
     public String print(Object o) {
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_method_Short.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_method_Short.java
index 89119cf..112ed47 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_method_Short.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/TransducedAccessor_method_Short.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2022 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
@@ -26,6 +26,7 @@
  *
  * @see TransducedAccessor#get
  */
+@SuppressWarnings({"deprecation"})
 public final class TransducedAccessor_method_Short extends DefaultTransducedAccessor {
     @Override
     public String print(Object o) {
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/unmarshaller/Base64Data.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/unmarshaller/Base64Data.java
index 44a8eb6..874d5f1 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/unmarshaller/Base64Data.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/unmarshaller/Base64Data.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2022 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
@@ -206,6 +206,7 @@
      * and returns the character at the specified position.
      */
     @Override
+    @SuppressWarnings({"deprecation"})
     public char charAt(int index) {
         // we assume that the length() method is called before this method
         // (otherwise how would the caller know that the index is valid?)
@@ -273,12 +274,14 @@
      * Returns the base64 encoded string of this data.
      */
     @Override
+    @SuppressWarnings({"deprecation"})
     public String toString() {
         get();  // fill in the buffer
         return DatatypeConverterImpl._printBase64Binary(data, 0, dataLen);
     }
 
     @Override
+    @SuppressWarnings({"deprecation"})
     public void writeTo(char[] buf, int start) {
         get();
         DatatypeConverterImpl._printBase64Binary(data, 0, dataLen, buf, start);
@@ -291,6 +294,7 @@
         output.text(data, dataLen);
     }
 
+    @SuppressWarnings({"deprecation"})
     public void writeTo(XMLStreamWriter output) throws IOException, XMLStreamException {
         get();
         DatatypeConverterImpl._printBase64Binary(data, 0, dataLen, output);
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/unmarshaller/LeafPropertyXsiLoader.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/unmarshaller/LeafPropertyXsiLoader.java
index 1ffe74f..0d4aa6e 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/unmarshaller/LeafPropertyXsiLoader.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/unmarshaller/LeafPropertyXsiLoader.java
@@ -43,6 +43,7 @@
         loader.startElement(state, ea);
     }
 
+    @SuppressWarnings({"deprecation"})
     protected Loader selectLoader(UnmarshallingContext.State state, TagName ea) throws SAXException {
 
         UnmarshallingContext context = state.getContext();
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/unmarshaller/UnmarshallerImpl.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/unmarshaller/UnmarshallerImpl.java
index 10354bd..efd33cf 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/unmarshaller/UnmarshallerImpl.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/unmarshaller/UnmarshallerImpl.java
@@ -118,9 +118,7 @@
                  // a proper schemaLocation.
                  parserFactory.setValidating(false);
                  reader = parserFactory.newSAXParser().getXMLReader();
-             } catch (ParserConfigurationException e) {
-                 throw new JAXBException(e);
-             } catch (SAXException e) {
+             } catch (ParserConfigurationException | SAXException e) {
                  throw new JAXBException(e);
              }
          }
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/unmarshaller/UnmarshallingContext.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/unmarshaller/UnmarshallingContext.java
index 51bd846..234cdff 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/unmarshaller/UnmarshallingContext.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/unmarshaller/UnmarshallingContext.java
@@ -365,9 +365,7 @@
         public Object createInstance() throws SAXException {
             try {
                 return method.invoke(factorInstance);
-            } catch (IllegalAccessException e) {
-                getInstance().handleError(e,false);
-            } catch (InvocationTargetException e) {
+            } catch (ReflectiveOperationException e) {
                 getInstance().handleError(e,false);
             }
             return null; // can never be executed
@@ -657,11 +655,7 @@
         }
         try {
             return beanInfo.createInstance(this);
-        } catch (IllegalAccessException e) {
-            Loader.reportError("Unable to create an instance of "+beanInfo.jaxbType.getName(),e,false);
-        } catch (InvocationTargetException e) {
-            Loader.reportError("Unable to create an instance of "+beanInfo.jaxbType.getName(),e,false);
-        } catch (InstantiationException e) {
+        } catch (ReflectiveOperationException e) {
             Loader.reportError("Unable to create an instance of "+beanInfo.jaxbType.getName(),e,false);
         }
         return null;    // can never be here
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/unmarshaller/XsiNilLoader.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/unmarshaller/XsiNilLoader.java
index e9d3640..57c7c48 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/unmarshaller/XsiNilLoader.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/unmarshaller/XsiNilLoader.java
@@ -36,6 +36,7 @@
     }
 
     @Override
+    @SuppressWarnings({"deprecation"})
     protected Loader selectLoader(UnmarshallingContext.State state, TagName ea) throws SAXException {
         int idx = ea.atts.getIndex(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI,"nil");
 
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/unmarshaller/XsiTypeLoader.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/unmarshaller/XsiTypeLoader.java
index 85e41a6..e7b87d3 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/unmarshaller/XsiTypeLoader.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/unmarshaller/XsiTypeLoader.java
@@ -51,6 +51,7 @@
         loader.startElement(state,ea);
     }
 
+    @SuppressWarnings({"deprecation"})
     /*pacakge*/ static JaxBeanInfo parseXsiType(UnmarshallingContext.State state, TagName ea, @Nullable JaxBeanInfo defaultBeanInfo) throws SAXException {
         UnmarshallingContext context = state.getContext();
         JaxBeanInfo beanInfo = null;
diff --git a/jaxb-ri/runtime/impl/src/test/java/XMLResolverAdapter.java b/jaxb-ri/runtime/impl/src/test/java/XMLResolverAdapter.java
index 3278f1d..3c7c547 100644
--- a/jaxb-ri/runtime/impl/src/test/java/XMLResolverAdapter.java
+++ b/jaxb-ri/runtime/impl/src/test/java/XMLResolverAdapter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2022 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
@@ -44,9 +44,7 @@
             ss.setReader(is.getCharacterStream());
             // this ignores the is.getEncoding(), but that's JAXP's fault.
             return inputFactory.createXMLStreamReader(ss);
-        } catch (SAXException e) {
-            throw new XMLStreamException(e);
-        } catch (IOException e) {
+        } catch (SAXException | IOException e) {
             throw new XMLStreamException(e);
         }
     }
diff --git a/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/CompositeStructureTest.java b/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/CompositeStructureTest.java
index af8d95c..9702b8a 100644
--- a/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/CompositeStructureTest.java
+++ b/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/CompositeStructureTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2022 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
@@ -12,6 +12,7 @@
 
 import java.util.Arrays;
 import java.io.StringWriter;
+import java.util.Collections;
 
 import jakarta.xml.bind.JAXBElement;
 import jakarta.xml.bind.annotation.adapters.HexBinaryAdapter;
@@ -39,7 +40,7 @@
         TypeReference tr4 = new TypeReference(new QName("","zoo"),byte[].class,
                 this.getClass().getMethod("test1").getAnnotation(XmlJavaTypeAdapter.class));
         JAXBRIContext c = JAXBRIContext.newInstance(new Class[0],
-                Arrays.asList(tr1,tr2,tr3,tr4),"",false);
+                Arrays.asList(tr1,tr2,tr3,tr4), Collections.emptyMap(), "",false, null);
 
         CompositeStructure cs = new CompositeStructure();
         cs.bridges = new Bridge[] {
diff --git a/jaxb-ri/txw/compiler/src/main/java/com/sun/tools/txw2/TxwOptions.java b/jaxb-ri/txw/compiler/src/main/java/com/sun/tools/txw2/TxwOptions.java
index c6594e0..c2a5250 100644
--- a/jaxb-ri/txw/compiler/src/main/java/com/sun/tools/txw2/TxwOptions.java
+++ b/jaxb-ri/txw/compiler/src/main/java/com/sun/tools/txw2/TxwOptions.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2022 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
@@ -76,6 +76,16 @@
     public Language language;
 
     /**
+     * If true XML security features when parsing XML documents will be disabled.
+     * The default value is false.
+     * <p>
+     * Boolean
+     *
+     * @since 2.2.6
+     */
+    public boolean disableXmlSecurity;
+
+    /**
      * Type of the schema language.
      */
     public enum Language {
@@ -151,6 +161,10 @@
             chainMethod = true;
             return 1;
         }
+        if (args[i].equals("-disableXmlSecurity")) {
+            disableXmlSecurity = true;
+            return 1;
+        }
         return 0;   // unrecognized
     }
 
diff --git a/jaxb-ri/txw/compiler/src/main/java/com/sun/tools/txw2/XmlSchemaLoader.java b/jaxb-ri/txw/compiler/src/main/java/com/sun/tools/txw2/XmlSchemaLoader.java
index 62d0897..9c79d1b 100644
--- a/jaxb-ri/txw/compiler/src/main/java/com/sun/tools/txw2/XmlSchemaLoader.java
+++ b/jaxb-ri/txw/compiler/src/main/java/com/sun/tools/txw2/XmlSchemaLoader.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2022 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
@@ -10,6 +10,7 @@
 
 package com.sun.tools.txw2;
 
+import com.sun.xml.xsom.parser.XmlFactory;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 import com.sun.tools.txw2.model.NodeSet;
@@ -28,7 +29,7 @@
 
     @Override
     public NodeSet build(TxwOptions options) throws SAXException {
-        XSOMParser xsom = new XSOMParser();
+        XSOMParser xsom = new XSOMParser(XmlFactory.createParserFactory(options.disableXmlSecurity));
         xsom.parse(in);
         return XmlSchemaBuilder.build(xsom.getResult(),options);
     }
diff --git a/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/api/impl/s2j/SchemaCompilerImpl.java b/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/api/impl/s2j/SchemaCompilerImpl.java
index 168275a..95dbdc6 100644
--- a/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/api/impl/s2j/SchemaCompilerImpl.java
+++ b/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/api/impl/s2j/SchemaCompilerImpl.java
@@ -93,6 +93,7 @@
 
     @NotNull
     @Override
+    @SuppressWarnings({"deprecation"})
     public Options getOptions() {
         return opts;
     }
diff --git a/jaxb-ri/xsom/src/main/java/com/sun/xml/xsom/impl/parser/Messages.java b/jaxb-ri/xsom/src/main/java/com/sun/xml/xsom/impl/parser/Messages.java
index 21bef66..756abd0 100644
--- a/jaxb-ri/xsom/src/main/java/com/sun/xml/xsom/impl/parser/Messages.java
+++ b/jaxb-ri/xsom/src/main/java/com/sun/xml/xsom/impl/parser/Messages.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2022 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
@@ -68,4 +68,7 @@
 
     public static final String JAXP_SUPPORTED_PROPERTY =
         "JAXPSupportedProperty"; // arg:1
+
+    public static final String INVALID_JAXP_IMPLEMENTATION =
+            "INVALID_JAXP_IMPLEMENTATION"; // arg:0
 }
diff --git a/jaxb-ri/xsom/src/main/java/com/sun/xml/xsom/parser/XSOMParser.java b/jaxb-ri/xsom/src/main/java/com/sun/xml/xsom/parser/XSOMParser.java
index 79eed2f..0738944 100644
--- a/jaxb-ri/xsom/src/main/java/com/sun/xml/xsom/parser/XSOMParser.java
+++ b/jaxb-ri/xsom/src/main/java/com/sun/xml/xsom/parser/XSOMParser.java
@@ -10,79 +10,63 @@
 
 package com.sun.xml.xsom.parser;
 
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URL;
-import java.util.Set;
-import java.util.HashSet;
-
-import javax.xml.parsers.SAXParserFactory;
-
+import com.sun.xml.xsom.XSSchemaSet;
+import com.sun.xml.xsom.impl.parser.NGCCRuntimeEx;
+import com.sun.xml.xsom.impl.parser.ParserContext;
+import com.sun.xml.xsom.impl.parser.state.Schema;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.EntityResolver;
 import org.xml.sax.ErrorHandler;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 
-import com.sun.xml.xsom.XSSchemaSet;
-import com.sun.xml.xsom.impl.parser.NGCCRuntimeEx;
-import com.sun.xml.xsom.impl.parser.ParserContext;
-import com.sun.xml.xsom.impl.parser.state.Schema;
+import javax.xml.parsers.SAXParserFactory;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Set;
 
 /**
  * Parses possibly multiple W3C XML Schema files and compose
  * them into one grammar.
- * 
- * @author
- *     Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
+ *
+ * @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
  */
 public final class XSOMParser {
 
     private EntityResolver entityResolver;
     private ErrorHandler userErrorHandler;
-    
+
     private AnnotationParserFactory apFactory;
-    
+
     private final ParserContext context;
-    
+
     /**
-    * Creates a new XSOMParser by using a SAX parser from JAXP.
-     * @deprecated Unsafe, use XSOMParser(factory) instead with 
-     * security features initialized by setting 
-     * XMLConstants.FEATURE_SECURE_PROCESSING feature.
-    */
-    @Deprecated
-   public XSOMParser() {
-       this(new JAXPParser());
-   }
-    
-   /**
-    * Creates a new XSOMParser that uses the given SAXParserFactory
-    * for creating new SAX parsers.
-    * 
-    * The caller needs to configure
-    * it properly. Don't forget to call <code>setNamespaceAware(true)</code>
-    * or you'll see some strange errors.
-    */
-   public XSOMParser( SAXParserFactory factory ) {
-       this( new JAXPParser(factory) );
-   }
-    
-   /**
-    * Creates a new XSOMParser that reads XML Schema from non-standard
-    * inputs.
-    * 
-    * By implementing the {@link XMLParser} interface, XML Schema
-    * can be read from something other than XML.
-    * 
-    * @param   parser
-    *      This parser will be called to parse XML Schema documents.
-    */
+     * Creates a new XSOMParser that uses the given SAXParserFactory
+     * for creating new SAX parsers.
+     * <p>
+     * The caller needs to configure
+     * it properly. Don't forget to call <code>setNamespaceAware(true)</code>
+     * or you'll see some strange errors.
+     */
+    public XSOMParser(SAXParserFactory factory) {
+        this(new JAXPParser(factory));
+    }
+
+    /**
+     * Creates a new XSOMParser that reads XML Schema from non-standard
+     * inputs.
+     * <p>
+     * By implementing the {@link XMLParser} interface, XML Schema
+     * can be read from something other than XML.
+     *
+     * @param parser This parser will be called to parse XML Schema documents.
+     */
     public XSOMParser(XMLParser parser) {
-        context = new ParserContext(this,parser);
+        context = new ParserContext(this, parser);
     }
 
     /**
@@ -94,7 +78,7 @@
      * references to other schemas, XSOM will fail to resolve them.
      * To specify an system ID with a stream, use {@link InputSource}
      */
-    public void parse( InputStream is ) throws SAXException {
+    public void parse(InputStream is) throws SAXException {
         parse(new InputSource(is));
     }
 
@@ -107,31 +91,31 @@
      * references to other schemas, XSOM will fail to resolve them.
      * To specify an system ID with a reader, use {@link InputSource}
      */
-    public void parse( Reader reader ) throws SAXException {
+    public void parse(Reader reader) throws SAXException {
         parse(new InputSource(reader));
     }
 
     /**
      * Parses a new XML Schema document.
      */
-    public void parse( File schema ) throws SAXException, IOException {
+    public void parse(File schema) throws SAXException, IOException {
         parse(schema.toURI().toURL());
     }
-    
+
     /**
      * Parses a new XML Schema document.
      */
-    public void parse( URL url ) throws SAXException {
-        parse( url.toExternalForm() );
+    public void parse(URL url) throws SAXException {
+        parse(url.toExternalForm());
     }
-    
+
     /**
      * Parses a new XML Schema document.
      */
-    public void parse( String systemId ) throws SAXException {
+    public void parse(String systemId) throws SAXException {
         parse(new InputSource(systemId));
     }
-    
+
     /**
      * Parses a new XML Schema document.
      *
@@ -139,25 +123,24 @@
      * Note that if the {@link InputSource} does not have a system ID,
      * XSOM will fail to resolve them.
      */
-    public void parse( InputSource source ) throws SAXException {
+    public void parse(InputSource source) throws SAXException {
         context.parse(source);
     }
-    
-    
-    
+
+
     /**
      * Gets the parser implemented as a ContentHandler.
-     * 
+     * <p>
      * One can feed XML Schema as SAX events to this interface to
      * parse a schema. To parse multiple schema files, feed multiple
      * sets of events.
-     * 
+     *
      * <p>
      * If you don't send a complete event sequence from a startDocument
      * event to an endDocument event, the state of XSOMParser can become
      * unstable. This sometimes happen when you encounter an error while
      * generating SAX events. Don't call the getResult method in that case.
-     * 
+     *
      * <p>
      * This way of reading XML Schema can be useful when XML Schema is
      * not available as a stand-alone XML document.
@@ -165,22 +148,20 @@
      */
     public ContentHandler getParserHandler() {
         NGCCRuntimeEx runtime = context.newNGCCRuntime();
-        Schema s = new Schema(runtime,false,null);
+        Schema s = new Schema(runtime, false, null);
         runtime.setRootHandler(s);
         return runtime;
     }
-    
+
     /**
      * Gets the parsed result. Don't call this method until
      * you parse all the schemas.
-     * 
-     * @return
-     *      If there was any parse error, this method returns null.
-     *      To receive error information, specify your error handler
-     *      through the setErrorHandler method.
-     * @exception SAXException
-     *      This exception will never be thrown unless it is thrown
-     *      by an error handler.
+     *
+     * @return If there was any parse error, this method returns null.
+     * To receive error information, specify your error handler
+     * through the setErrorHandler method.
+     * @throws SAXException This exception will never be thrown unless it is thrown
+     *                      by an error handler.
      */
     public XSSchemaSet getResult() throws SAXException {
         return context.getResult();
@@ -190,26 +171,28 @@
      * Gets the set of {@link SchemaDocument} that represents
      * parsed documents so far.
      *
-     * @return
-     *      can be empty but never null.
+     * @return can be empty but never null.
      */
     public Set<SchemaDocument> getDocuments() {
         return new HashSet<>(context.parsedDocuments.keySet());
     }
-    
+
     public EntityResolver getEntityResolver() {
         return entityResolver;
     }
+
     /**
      * Set an entity resolver that is used to resolve things
      * like {@code <xsd:import>} and {@code <xsd:include>}.
      */
-    public void setEntityResolver( EntityResolver resolver ) {
+    public void setEntityResolver(EntityResolver resolver) {
         this.entityResolver = resolver;
     }
+
     public ErrorHandler getErrorHandler() {
         return userErrorHandler;
     }
+
     /**
      * Set an error handler that receives all the errors encountered
      * during the parsing.
@@ -220,22 +203,24 @@
 
     /**
      * Sets the annotation parser.
-     * 
+     * <p>
      * Annotation parser can be used to parse application-specific
      * annotations inside a schema.
-     * 
+     *
      * <p>
      * For each annotation, new instance of this class will be
      * created and used to parse {@code <xs:annotation>}.
      */
-    public void setAnnotationParser( final Class annParser ) {
-        setAnnotationParser( new AnnotationParserFactory() {
+    public void setAnnotationParser(final Class<? extends AnnotationParser> annParser) {
+        setAnnotationParser(new AnnotationParserFactory() {
             public AnnotationParser create() {
                 try {
-                    return (AnnotationParser)annParser.getConstructor().newInstance();
-                } catch( IllegalAccessException e ) {
+                    return
+
+                            annParser.getConstructor().newInstance();
+                } catch (IllegalAccessException e) {
                     throw new IllegalAccessError(e.getMessage());
-                } catch(ReflectiveOperationException e ) {
+                } catch (ReflectiveOperationException e) {
                     throw new InstantiationError(e.getMessage());
                 }
             }
@@ -244,11 +229,11 @@
 
     /**
      * Sets the annotation parser factory.
-     * 
+     *
      * <p>
      * The specified factory will be used to create AnnotationParsers.
      */
-    public void setAnnotationParser( AnnotationParserFactory factory ) {
+    public void setAnnotationParser(AnnotationParserFactory factory) {
         this.apFactory = factory;
     }
 
diff --git a/jaxb-ri/xsom/src/main/java/com/sun/xml/xsom/parser/XmlFactory.java b/jaxb-ri/xsom/src/main/java/com/sun/xml/xsom/parser/XmlFactory.java
new file mode 100644
index 0000000..0bfeccb
--- /dev/null
+++ b/jaxb-ri/xsom/src/main/java/com/sun/xml/xsom/parser/XmlFactory.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013, 2022 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 com.sun.xml.xsom.parser;
+
+import com.sun.xml.xsom.impl.parser.Messages;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParserFactory;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Provides helper methods for creating properly configured XML parser
+ * factory instances with namespace support turned on and configured for
+ * security.
+ *
+ * @author snajper
+ */
+public final class XmlFactory {
+
+    private static final Logger LOGGER = Logger.getLogger(XmlFactory.class.getName());
+
+    /**
+     * If true XML security features when parsing XML documents will be disabled.
+     * The default value is false.
+     * <p>
+     * Boolean
+     */
+    private static final String DISABLE_XML_SECURITY = "org.glassfish.jaxb.disableXmlSecurity";
+
+    private static final boolean XML_SECURITY_DISABLED = AccessController.doPrivileged(
+            new PrivilegedAction<>() {
+                @Override
+                public Boolean run() {
+                    return Boolean.getBoolean(DISABLE_XML_SECURITY);
+                }
+            }
+    );
+
+    private XmlFactory() {
+    }
+
+    private static boolean isXMLSecurityDisabled(boolean runtimeSetting) {
+        return XML_SECURITY_DISABLED || runtimeSetting;
+    }
+
+    /**
+     * Returns properly configured (e.g. security features) parser factory
+     * - namespaceAware == true
+     * - securityProcessing == is set based on security processing property, default is true
+     */
+    public static SAXParserFactory createParserFactory(boolean disableSecureProcessing) throws IllegalStateException {
+        try {
+            SAXParserFactory factory = SAXParserFactory.newInstance();
+            if (LOGGER.isLoggable(Level.FINE)) {
+                LOGGER.log(Level.FINE, "SAXParserFactory instance: {0}", factory);
+            }
+            factory.setNamespaceAware(true);
+            factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, !isXMLSecurityDisabled(disableSecureProcessing));
+            return factory;
+        } catch (ParserConfigurationException | SAXNotRecognizedException | SAXNotSupportedException ex) {
+            LOGGER.log(Level.SEVERE, null, ex);
+            throw new IllegalStateException(ex);
+        } catch (AbstractMethodError er) {
+            LOGGER.log(Level.SEVERE, null, er);
+            throw new IllegalStateException(Messages.format(Messages.INVALID_JAXP_IMPLEMENTATION), er);
+        }
+    }
+}
diff --git a/jaxb-ri/xsom/src/main/resources/com/sun/xml/xsom/impl/parser/Messages.properties b/jaxb-ri/xsom/src/main/resources/com/sun/xml/xsom/impl/parser/Messages.properties
index 1471bf7..c31fc5e 100644
--- a/jaxb-ri/xsom/src/main/resources/com/sun/xml/xsom/impl/parser/Messages.properties
+++ b/jaxb-ri/xsom/src/main/resources/com/sun/xml/xsom/impl/parser/Messages.properties
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 2022 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
@@ -61,5 +61,7 @@
     Property "{0}" is not supported by used JAXP implementation.
 
 JAXPSupportedProperty = \
-    Property "{0}" is supported and has been successfuly set by used JAXP implementation.
+    Property "{0}" is supported and has been successfully set by used JAXP implementation.
 
+INVALID_JAXP_IMPLEMENTATION = \
+    You are running with invalid JAXP api or implementation. JAXP api/implementation of version 1.3.1 (included in JDK6) or higher is required. In case you are using ant, make sure ant 1.7.0 or higher is used - older versions of ant contain JAXP api/impl version 1.2 (in xml-apis.jar). If you want to keep using older ant versions, you have to configure it to use higher the JAXP api/impl versions.
diff --git a/jaxb-ri/xsom/src/test/java/com/sun/xml/xsom/test/AbstractXSOMTest.java b/jaxb-ri/xsom/src/test/java/com/sun/xml/xsom/test/AbstractXSOMTest.java
index 8170187..1b5bfe5 100644
--- a/jaxb-ri/xsom/src/test/java/com/sun/xml/xsom/test/AbstractXSOMTest.java
+++ b/jaxb-ri/xsom/src/test/java/com/sun/xml/xsom/test/AbstractXSOMTest.java
@@ -1,7 +1,7 @@
 package com.sun.xml.xsom.test;
 
 /*
- * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2022 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
@@ -10,6 +10,7 @@
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
+import com.sun.xml.xsom.parser.XmlFactory;
 import junit.framework.TestCase;
 import com.sun.xml.xsom.XSSchemaSet;
 import com.sun.xml.xsom.parser.XSOMParser;
@@ -23,7 +24,7 @@
      * Loads a schema set from XSDs in the resource.
      */
     protected final XSSchemaSet load(String... resourceNames) throws SAXException {
-        XSOMParser p = new XSOMParser();
+        XSOMParser p = new XSOMParser(XmlFactory.createParserFactory(false));
         for (String n : resourceNames) {
             p.parse(getClass().getResource(n));
         }
diff --git a/jaxb-ri/xsom/src/test/java/com/sun/xml/xsom/test/ERDriver.java b/jaxb-ri/xsom/src/test/java/com/sun/xml/xsom/test/ERDriver.java
index 4b702e7..76e2a43 100644
--- a/jaxb-ri/xsom/src/test/java/com/sun/xml/xsom/test/ERDriver.java
+++ b/jaxb-ri/xsom/src/test/java/com/sun/xml/xsom/test/ERDriver.java
@@ -1,7 +1,7 @@
 package com.sun.xml.xsom.test;
 
 /*
- * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2022 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
@@ -11,6 +11,7 @@
  */
 
 import com.sun.xml.xsom.parser.XSOMParser;
+import com.sun.xml.xsom.parser.XmlFactory;
 import org.xml.sax.EntityResolver;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
@@ -24,7 +25,7 @@
  */
 public class ERDriver {
     public static void main(String[] args) throws Exception {
-        XSOMParser p = new XSOMParser();
+        XSOMParser p = new XSOMParser(XmlFactory.createParserFactory(false));
         p.setEntityResolver(new EntityResolverImpl());
 
         // SAX parser -> XSOM ContentHandler
diff --git a/jaxb-ri/xsom/src/test/java/com/sun/xml/xsom/test/SCDDriver.java b/jaxb-ri/xsom/src/test/java/com/sun/xml/xsom/test/SCDDriver.java
index 52f6f1e..d9376b1 100644
--- a/jaxb-ri/xsom/src/test/java/com/sun/xml/xsom/test/SCDDriver.java
+++ b/jaxb-ri/xsom/src/test/java/com/sun/xml/xsom/test/SCDDriver.java
@@ -1,7 +1,7 @@
 package com.sun.xml.xsom.test;
 
 /*
- * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2022 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
@@ -14,6 +14,7 @@
 import com.sun.xml.xsom.XSComponent;
 import com.sun.xml.xsom.XSSchemaSet;
 import com.sun.xml.xsom.parser.XSOMParser;
+import com.sun.xml.xsom.parser.XmlFactory;
 import com.sun.xml.xsom.util.ComponentNameFunction;
 import org.xml.sax.Locator;
 
@@ -28,7 +29,7 @@
  */
 public class SCDDriver {
     public static void main(String[] args) throws Exception {
-        XSOMParser p = new XSOMParser();
+        XSOMParser p = new XSOMParser(XmlFactory.createParserFactory(false));
 
         for( int i=1; i<args.length; i++ )
             p.parse(args[i]);
diff --git a/jaxb-ri/xsom/src/test/java/com/sun/xml/xsom/test/XSOMParserTest.java b/jaxb-ri/xsom/src/test/java/com/sun/xml/xsom/test/XSOMParserTest.java
index 7393da4..a1b8201 100644
--- a/jaxb-ri/xsom/src/test/java/com/sun/xml/xsom/test/XSOMParserTest.java
+++ b/jaxb-ri/xsom/src/test/java/com/sun/xml/xsom/test/XSOMParserTest.java
@@ -1,7 +1,7 @@
 package com.sun.xml.xsom.test;
 
 /*
- * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2022 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
@@ -20,6 +20,7 @@
 import com.sun.xml.xsom.XSSchemaSet;
 import com.sun.xml.xsom.parser.XSOMParser;
 import com.sun.xml.xsom.parser.SchemaDocument;
+import com.sun.xml.xsom.parser.XmlFactory;
 import junit.framework.*;
 import org.xml.sax.InputSource;
 
@@ -45,7 +46,7 @@
         if (docURL == null) {
             docURL = new URL(docURLStr);
 
-            instance = new XSOMParser();
+            instance = new XSOMParser(XmlFactory.createParserFactory(false));
         }
     }