remove obsolete/unused classes
Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/bytecode/ClassTailor.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/bytecode/ClassTailor.java
deleted file mode 100644
index 75d6c97..0000000
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/bytecode/ClassTailor.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Copyright (c) 1997, 2020 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.bytecode;
-
-import org.glassfish.jaxb.core.Utils;
-
-import java.io.*;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Replaces a few constant pool tokens from a class "template" and then loads it into the VM.
- *
- * @author Kohsuke Kawaguchi
- */
-public final class ClassTailor {
-
- private ClassTailor() {} // no instanciation please
-
- private static final Logger logger = Utils.getClassLogger();
-
- /**
- * Returns the class name in the JVM format (such as "java/lang/String")
- */
- public static String toVMClassName( Class c ) {
- assert !c.isPrimitive();
- if(c.isArray())
- // I have no idea why it is designed like this, but javap says so.
- return toVMTypeName(c);
- return c.getName().replace('.','/');
- }
-
- public static String toVMTypeName( Class c ) {
- if(c.isArray()) {
- // TODO: study how an array type is encoded.
- return '['+toVMTypeName(c.getComponentType());
- }
- if(c.isPrimitive()) {
- if(c==Boolean.TYPE) return "Z";
- if(c==Character.TYPE) return "C";
- if(c==Byte.TYPE) return "B";
- if(c==Double.TYPE) return "D";
- if(c==Float.TYPE) return "F";
- if(c==Integer.TYPE) return "I";
- if(c==Long.TYPE) return "J";
- if(c==Short.TYPE) return "S";
-
- throw new IllegalArgumentException(c.getName());
- }
- return 'L'+c.getName().replace('.','/')+';';
- }
-
-
-
- public static byte[] tailor( Class templateClass, String newClassName, String... replacements ) {
- String vmname = toVMClassName(templateClass);
- return tailor(
- SecureLoader.getClassClassLoader(templateClass).getResourceAsStream(vmname+".class"),
- vmname, newClassName, replacements );
- }
-
-
- /**
- * Customizes a class file by replacing constant pools.
- *
- * @param image
- * The image of the template class.
- * @param replacements
- * A list of pair of strings that specify the substitution
- * {@code String[]{search_0, replace_0, search_1, replace_1, ..., search_n, replace_n }}
- *
- * The search strings found in the constant pool will be replaced by the corresponding
- * replacement string.
- */
- public static byte[] tailor( InputStream image, String templateClassName, String newClassName, String... replacements ) {
- DataInputStream in = new DataInputStream(image);
-
- try {
- ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
- DataOutputStream out = new DataOutputStream(baos);
-
- // skip until the constant pool count
- long l = in.readLong();
- out.writeLong(l);
-
- // read the constant pool size
- short count = in.readShort();
- out.writeShort(count);
-
- // replace constant pools
- for( int i=0; i<count; i++ ) {
- byte tag = in.readByte();
- out.writeByte(tag);
- switch(tag) {
- case 0:
- // this isn't described in the spec,
- // but class files often seem to have this '0' tag.
- // we can apparently just ignore it, but not sure
- // what this really means.
- break;
-
- case 1: // CONSTANT_UTF8
- {
- String value = in.readUTF();
- if(value.equals(templateClassName))
- value = newClassName;
- else {
- for( int j=0; j<replacements.length; j+=2 )
- if(value.equals(replacements[j])) {
- value = replacements[j+1];
- break;
- }
- }
- out.writeUTF(value);
- }
- break;
-
- case 3: // CONSTANT_Integer
- case 4: // CONSTANT_Float
- out.writeInt(in.readInt());
- break;
-
- case 5: // CONSTANT_Long
- case 6: // CONSTANT_Double
- i++; // doubles and longs take two entries
- out.writeLong(in.readLong());
- break;
-
- case 7: // CONSTANT_Class
- case 8: // CONSTANT_String
- out.writeShort(in.readShort());
- break;
-
- case 9: // CONSTANT_Fieldref
- case 10: // CONSTANT_Methodref
- case 11: // CONSTANT_InterfaceMethodref
- case 12: // CONSTANT_NameAndType
- out.writeInt(in.readInt());
- break;
-
- default:
- throw new IllegalArgumentException("Unknown constant type "+tag);
- }
- }
-
- // then copy the rest
- byte[] buf = new byte[512];
- int len;
- while((len=in.read(buf))>0)
- out.write(buf,0,len);
-
- in.close();
- out.close();
-
- // by now we got the properly tailored class file image
- return baos.toByteArray();
-
- } catch( IOException e ) {
- // never happen
- logger.log(Level.WARNING,"failed to tailor",e);
- return null;
- }
- }
-}
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/bytecode/SecureLoader.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/bytecode/SecureLoader.java
deleted file mode 100644
index 5d22ad4..0000000
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/bytecode/SecureLoader.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 1997, 2020 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.bytecode;
-
-/**
- * Class defined for safe calls of getClassLoader methods of any kind (context/system/class
- * classloader. This MUST be package private and defined in every package which
- * uses such invocations.
- * @author snajper
- */
-class SecureLoader {
-
- static ClassLoader getContextClassLoader() {
- if (System.getSecurityManager() == null) {
- return Thread.currentThread().getContextClassLoader();
- } else {
- return (ClassLoader) java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
- public java.lang.Object run() {
- return Thread.currentThread().getContextClassLoader();
- }
- });
- }
- }
-
- static ClassLoader getClassClassLoader(final Class c) {
- if (System.getSecurityManager() == null) {
- return c.getClassLoader();
- } else {
- return (ClassLoader) java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
- public java.lang.Object run() {
- return c.getClassLoader();
- }
- });
- }
- }
-
- static ClassLoader getSystemClassLoader() {
- if (System.getSecurityManager() == null) {
- return ClassLoader.getSystemClassLoader();
- } else {
- return (ClassLoader) java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
- public java.lang.Object run() {
- return ClassLoader.getSystemClassLoader();
- }
- });
- }
- }
-
-}
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/bytecode/package-info.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/bytecode/package-info.java
deleted file mode 100644
index d7c2328..0000000
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/bytecode/package-info.java
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * Copyright (c) 2017, 2020 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
- */
-
-/**
- * Code that deals with low level byte code manipulation.
- */
-package org.glassfish.jaxb.runtime.v2.bytecode;
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/FilterTransducer.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/FilterTransducer.java
index 5b2ee93..8679106 100644
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/FilterTransducer.java
+++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/FilterTransducer.java
@@ -1,9 +1,5 @@
/*
-<<<<<<< HEAD:jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/FilterTransducer.java
- * Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
-=======
- * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
->>>>>>> parent of 263e92e (Revert optimization removal (#1352)):jaxb-ri/runtime/impl/src/main/java/com/sun/xml/bind/v2/runtime/FilterTransducer.java
+ * 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
@@ -34,30 +30,37 @@
this.core = core;
}
+ @Override
public boolean useNamespace() {
return core.useNamespace();
}
+ @Override
public void declareNamespace(T o, XMLSerializer w) throws AccessorException {
core.declareNamespace(o, w);
}
+ @Override
public @NotNull CharSequence print(@NotNull T o) throws AccessorException {
return core.print(o);
}
+ @Override
public T parse(CharSequence lexical) throws AccessorException, SAXException {
return core.parse(lexical);
}
+ @Override
public void writeText(XMLSerializer w, T o, String fieldName) throws IOException, SAXException, XMLStreamException, AccessorException {
core.writeText(w, o, fieldName);
}
+ @Override
public void writeLeafElement(XMLSerializer w, Name tagName, T o, String fieldName) throws IOException, SAXException, XMLStreamException, AccessorException {
core.writeLeafElement(w,tagName,o,fieldName);
}
+ @Override
public QName getTypeName(T instance) {
return null;
}
diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/AccessorInjector.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/AccessorInjector.java
deleted file mode 100644
index c3f72b0..0000000
--- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/AccessorInjector.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 1997, 2020 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.reflect.opt;
-
-import org.glassfish.jaxb.core.Utils;
-import org.glassfish.jaxb.runtime.v2.bytecode.ClassTailor;
-
-import java.io.InputStream;
-import java.util.logging.Logger;
-
-/**
- * @author Kohsuke Kawaguchi
- */
-class AccessorInjector {
-
- private static final Logger logger = Utils.getClassLogger();
-
- protected static final boolean noOptimize =
- Utils.getSystemProperty(ClassTailor.class.getName()+".noOptimize")!=null;
-
- static {
- if(noOptimize)
- logger.info("The optimized code generation is disabled");
- }
-
- /**
- * Customizes a class file by replacing constant pools.
- *
- * @param templateClassName
- * The resource that contains the template class file.
- * @param replacements
- * A list of pair of strings that specify the substitution
- * {@code String[]{search_0, replace_0, search_1, replace_1, ..., search_n, replace_n }
- *
- * The search strings found in the constant pool will be replaced by the corresponding
- * replacement string.
- */
- private static byte[] tailor( String templateClassName, String newClassName, String... replacements ) {
- InputStream resource;
- if(CLASS_LOADER!=null)
- resource = CLASS_LOADER.getResourceAsStream(templateClassName+".class");
- else
- resource = ClassLoader.getSystemResourceAsStream(templateClassName+".class");
- if(resource==null)
- return null;
-
- return ClassTailor.tailor(resource,templateClassName,newClassName,replacements);
- }
-
- private static final ClassLoader CLASS_LOADER = SecureLoader.getClassClassLoader(AccessorInjector.class);
-
-}