public CompactedObjectInputStream(InputStream in, ClassLoader cl) throws IOException { super(in); mClassLoader = cl == null ? ClassHelper.getClassLoader() : cl; }
public static boolean isSetter(Method method) { return method.getName().startsWith("set") && !"set".equals(method.getName()) && Modifier.isPublic(method.getModifiers()) && method.getParameterCount() == 1 && isPrimitive(method.getParameterTypes()[0]); }
throws ClassNotFoundException, LinkageError { Class<?> clazz = resolvePrimitiveClassName(name); if (clazz != null) { return clazz; Class<?> elementClass = forName(elementClassName, classLoader); return Array.newInstance(elementClass, 0).getClass(); elementClassName = name.substring(1); Class<?> elementClass = forName(elementClassName, classLoader); return Array.newInstance(elementClass, 0).getClass(); classLoaderToUse = getClassLoader();
/** * Same as <code>Class.forName()</code>, except that it works for primitive * types. */ public static Class<?> forName(String name) throws ClassNotFoundException { return forName(name, getClassLoader()); }
@Override public boolean equals(Object obj) { if (obj == null || !(obj.getClass().getName().equals(this.getClass().getName()))) { return false; } Method[] methods = this.getClass().getMethods(); for (Method method1 : methods) { if (ClassHelper.isGetter(method1) && ClassHelper.isPrimitive(method1.getReturnType())) { Parameter parameter = method1.getAnnotation(Parameter.class); if (parameter != null && parameter.excluded()) { continue; } try { Method method2 = obj.getClass().getMethod(method1.getName(), method1.getParameterTypes()); Object value1 = method1.invoke(this, new Object[]{}); Object value2 = method2.invoke(obj, new Object[]{}); if ((value1 != null && value2 != null) && !value1.equals(value2)) { return false; } } catch (Exception e) { return true; } } } return true; } }
if (ClassHelper.isSetter(method)) { try { String value = compositeConfiguration.getString(extractPropertyName(getClass(), method)); if (StringUtils.isNotEmpty(value) && ClassHelper.isTypeMatch(method.getParameterTypes()[0], value)) { method.invoke(this, ClassHelper.convertPrimitive(method.getParameterTypes()[0], value));
localClass = ClassHelper.forNameWithThreadContextClassLoader(local); } catch (ClassNotFoundException e) { throw new IllegalStateException(e.getMessage(), e); stubClass = ClassHelper.forNameWithThreadContextClassLoader(stub); } catch (ClassNotFoundException e) { throw new IllegalStateException(e.getMessage(), e);
/** * mixin interface and delegates. * all class must be public. * * @param ics interface class array. * @param dcs delegate class array. * @return Mixin instance. */ public static Mixin mixin(Class<?>[] ics, Class<?>[] dcs) { return mixin(ics, dcs, ClassHelper.getCallerClassLoader(Mixin.class)); }
for (Method method : methods) { try { if (ClassHelper.isGetter(method)) { String name = method.getName(); String key = calculateAttributeFromGetter(name);
public static Class<?> forNameWithCallerClassLoader(String name, Class<?> caller) throws ClassNotFoundException { return forName(name, caller.getClassLoader()); }
@Override protected Class<?> findClass(final String qualifiedClassName) throws ClassNotFoundException { JavaFileObject file = classes.get(qualifiedClassName); if (file != null) { byte[] bytes = ((JavaFileObjectImpl) file).getByteCode(); return defineClass(qualifiedClassName, bytes, 0, bytes.length); } try { return ClassHelper.forNameWithCallerClassLoader(qualifiedClassName, getClass()); } catch (ClassNotFoundException nf) { return super.findClass(qualifiedClassName); } }
/** * Same as <code>Class.forName()</code>, except that it works for primitive * types. */ public static Class<?> forName(String name) throws ClassNotFoundException { return forName(name, getClassLoader()); }
if (ClassHelper.isSetter(method)) { try { String value = compositeConfiguration.getString(extractPropertyName(getClass(), method)); if (StringUtils.isNotEmpty(value) && ClassHelper.isTypeMatch(method.getParameterTypes()[0], value)) { method.invoke(this, ClassHelper.convertPrimitive(method.getParameterTypes()[0], value));
localClass = ClassHelper.forNameWithThreadContextClassLoader(local); } catch (ClassNotFoundException e) { throw new IllegalStateException(e.getMessage(), e); stubClass = ClassHelper.forNameWithThreadContextClassLoader(stub); } catch (ClassNotFoundException e) { throw new IllegalStateException(e.getMessage(), e);
@Override public boolean equals(Object obj) { if (obj == null || !(obj.getClass().getName().equals(this.getClass().getName()))) { return false; } Method[] methods = this.getClass().getMethods(); for (Method method1 : methods) { if (ClassHelper.isGetter(method1) && ClassHelper.isPrimitive(method1.getReturnType())) { Parameter parameter = method1.getAnnotation(Parameter.class); if (parameter != null && parameter.excluded()) { continue; } try { Method method2 = obj.getClass().getMethod(method1.getName(), method1.getParameterTypes()); Object value1 = method1.invoke(this, new Object[]{}); Object value2 = method2.invoke(obj, new Object[]{}); if ((value1 != null && value2 != null) && !value1.equals(value2)) { return false; } } catch (Exception e) { return true; } } } return true; } }
/** * mixin interface and delegates. * all class must be public. * * @param ics interface class array. * @param dcs delegate class array. * @return Mixin instance. */ public static Mixin mixin(Class<?>[] ics, Class<?>[] dcs) { return mixin(ics, dcs, ClassHelper.getCallerClassLoader(Mixin.class)); }
for (Method method : methods) { try { if (ClassHelper.isGetter(method)) { String name = method.getName(); String key = calculateAttributeFromGetter(name);
public static Class<?> forNameWithCallerClassLoader(String name, Class<?> caller) throws ClassNotFoundException { return forName(name, caller.getClassLoader()); }
@Override protected Class<?> findClass(final String qualifiedClassName) throws ClassNotFoundException { JavaFileObject file = classes.get(qualifiedClassName); if (file != null) { byte[] bytes = ((JavaFileObjectImpl) file).getByteCode(); return defineClass(qualifiedClassName, bytes, 0, bytes.length); } try { return ClassHelper.forNameWithCallerClassLoader(qualifiedClassName, getClass()); } catch (ClassNotFoundException nf) { return super.findClass(qualifiedClassName); } }
public CompactedObjectInputStream(InputStream in, ClassLoader cl) throws IOException { super(in); mClassLoader = cl == null ? ClassHelper.getClassLoader() : cl; }