/** * Retrieve the ClassLoader XStream uses to load classes. * * @since 1.1.1 */ public ClassLoader getClassLoader() { return classLoaderReference.getReference(); }
protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { ClassLoader classLoader = classLoaderReference.getReference(); if (classLoader == null) { return super.resolveClass(desc); } else { return Class.forName(desc.getName(), false, classLoader); } }
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); setupMappers(); int max = in.readInt(); arguments = new Object[max+2]; for (int i = 0; i < max; i++ ) { arguments[i] = in.readObject(); if (arguments[i] instanceof ClassLoaderReference) { arguments[max+1] = ((ClassLoaderReference)arguments[i]).getReference(); } } arguments[max] = new JVM(); }
private Mapper buildMapperDynamically(String className, Class[] constructorParamTypes, Object[] constructorParamValues) { try { Class type = Class.forName(className, false, classLoaderReference.getReference()); Constructor constructor = type.getConstructor(constructorParamTypes); return (Mapper)constructor.newInstance(constructorParamValues); } catch (Exception e) { throw new com.thoughtworks.xstream.InitializationException( "Could not instantiate mapper : " + className, e); } catch (LinkageError e) { throw new com.thoughtworks.xstream.InitializationException( "Could not instantiate mapper : " + className, e); } }
private void registerConverterDynamically(String className, int priority, Class[] constructorParamTypes, Object[] constructorParamValues) { try { Class type = Class.forName(className, false, classLoaderReference.getReference()); Constructor constructor = type.getConstructor(constructorParamTypes); Object instance = constructor.newInstance(constructorParamValues); if (instance instanceof Converter) { registerConverter((Converter)instance, priority); } else if (instance instanceof SingleValueConverter) { registerConverter((SingleValueConverter)instance, priority); } } catch (Exception e) { throw new com.thoughtworks.xstream.InitializationException( "Could not instantiate converter : " + className, e); } catch (LinkageError e) { throw new com.thoughtworks.xstream.InitializationException( "Could not instantiate converter : " + className, e); } }
public Class realClass(String elementName) { Class resultingClass = Primitives.primitiveType(elementName); if( resultingClass != null ){ return resultingClass; } try { boolean initialize = true; final ClassLoader classLoader; if (elementName.startsWith(XSTREAM_PACKAGE_ROOT)) { classLoader = DefaultMapper.class.getClassLoader(); } else { classLoader = classLoaderReference.getReference(); initialize = elementName.charAt(0) == '['; } return Class.forName(elementName, initialize, classLoader); } catch (ClassNotFoundException e) { throw new CannotResolveClassException(elementName); } }
/** * Construct an AnnotationMapper. * * @param wrapped the next {@link Mapper} in the chain * @since 1.4.5 */ public AnnotationMapper( final Mapper wrapped, final ConverterRegistry converterRegistry, final ConverterLookup converterLookup, final ClassLoaderReference classLoaderReference, final ReflectionProvider reflectionProvider) { super(wrapped); this.converterRegistry = converterRegistry; annotatedTypes.add(Object.class); setupMappers(); locked = true; final ClassLoader classLoader = classLoaderReference.getReference(); arguments = new Object[]{ this, classLoaderReference, reflectionProvider, converterLookup, new JVM(), classLoader != null ? classLoader : new TypedNull(ClassLoader.class)}; }
/** Straight copy of the registerConverterDynamically private method of XStream */ private void registerConverterDynamically( String className, int priority, Class[] constructorParamTypes, Object[] constructorParamValues) { try { Class type = Class.forName(className, false, getClassLoaderReference().getReference()); Constructor constructor = type.getConstructor(constructorParamTypes); Object instance = constructor.newInstance(constructorParamValues); if (instance instanceof Converter) { registerConverter((Converter) instance, priority); } else if (instance instanceof SingleValueConverter) { registerConverter((SingleValueConverter) instance, priority); } } catch (Exception e) { throw new com.thoughtworks.xstream.InitializationException( "Could not instantiate converter : " + className, e); } catch (LinkageError e) { throw new com.thoughtworks.xstream.InitializationException( "Could not instantiate converter : " + className, e); } }
Object proxy = null; if (HANDLER != null) { // we will not be able to resolve references to the proxy proxy = Proxy.newProxyInstance(classLoaderReference.getReference(), interfacesAsArray, DUMMY); Fields.write(HANDLER, proxy, handler); } else { proxy = Proxy.newProxyInstance(classLoaderReference.getReference(), interfacesAsArray, handler);
/** * Retrieve the ClassLoader XStream uses to load classes. * * @since 1.1.1 */ public ClassLoader getClassLoader() { return classLoaderReference.getReference(); }
/** * Retrieve the ClassLoader XStream uses to load classes. * * @since 1.1.1 */ public ClassLoader getClassLoader() { return classLoaderReference.getReference(); }
/** * Retrieve the ClassLoader XStream uses to load classes. * * @since 1.1.1 */ public ClassLoader getClassLoader() { return classLoaderReference.getReference(); }
/** * Retrieve the ClassLoader XStream uses to load classes. * * @since 1.1.1 */ public ClassLoader getClassLoader() { return classLoaderReference.getReference(); }
/** * Retrieve the ClassLoader XStream uses to load classes. * * @since 1.1.1 */ public ClassLoader getClassLoader() { return classLoaderReference.getReference(); }
protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { ClassLoader classLoader = classLoaderReference.getReference(); if (classLoader == null) { return super.resolveClass(desc); } else { return Class.forName(desc.getName(), false, classLoader); } }
@Override protected Class<?> resolveClass(final ObjectStreamClass desc) throws IOException, ClassNotFoundException { final ClassLoader classLoader = classLoaderReference.getReference(); if (classLoader == null) { return super.resolveClass(desc); } else { return Class.forName(desc.getName(), false, classLoader); } }
protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { ClassLoader classLoader = classLoaderReference.getReference(); if (classLoader == null) { return super.resolveClass(desc); } else { return Class.forName(desc.getName(), false, classLoader); } }
protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { ClassLoader classLoader = classLoaderReference.getReference(); if (classLoader == null) { return super.resolveClass(desc); } else { return Class.forName(desc.getName(), false, classLoader); } }
private Mapper buildMapperDynamically(final String className, final Class<?>[] constructorParamTypes, final Object[] constructorParamValues) { try { final Class<?> type = Class.forName(className, false, classLoaderReference.getReference()); final Constructor<?> constructor = type.getConstructor(constructorParamTypes); return (Mapper)constructor.newInstance(constructorParamValues); } catch (final Exception e) { throw new InitializationException("Could not instantiate mapper : " + className, e); } catch (final LinkageError e) { throw new InitializationException("Could not instantiate mapper : " + className, e); } }
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); setupMappers(); int max = in.readInt(); arguments = new Object[max+2]; for (int i = 0; i < max; i++ ) { arguments[i] = in.readObject(); if (arguments[i] instanceof ClassLoaderReference) { arguments[max+1] = ((ClassLoaderReference)arguments[i]).getReference(); } } arguments[max] = new JVM(); }