/** * Creates advice's class reader. */ private ClassReader createAdviceClassReader(final Class<? extends ProxyAdvice> advice) { InputStream inputStream = null; try { inputStream = ClassLoaderUtil.getClassAsStream(advice); return new ClassReader(inputStream); } catch (IOException ioex) { throw new ProxettaException(ioex); } finally { StreamUtil.close(inputStream); } }
/** * Defines class as a target. */ public T setTarget(final Class target) { assertTargetIsNotDefined(); try { targetInputStream = ClassLoaderUtil.getClassAsStream(target); if (targetInputStream == null) { throw new ProxettaException("Target class not found: " + target.getName()); } targetClass = target; targetClassName = target.getName(); } catch (IOException ioex) { StreamUtil.close(targetInputStream); throw new ProxettaException("Unable to stream class: " + target.getName(), ioex); } return _this(); }
inputStream = ClassLoaderUtil.getClassAsStream(nextSupername, classLoader); cr = new ClassReader(inputStream); } catch (IOException ioex) { ClassReader cr; try { inputStream = ClassLoaderUtil.getClassAsStream(next, classLoader); cr = new ClassReader(inputStream);
stream = ClassLoaderUtil.getClassAsStream(declaringClass); } catch (IOException ioex) { throw new ParamoException("Failed to read class bytes: " + declaringClass.getName(), ioex);
private MethodInfo getMethodSignatureForSingleMethod(Class klass) throws IOException { InputStream in = ClassLoaderUtil.getClassAsStream(klass.getName()); ClassReader classReader = new ClassReader(in); TargetClassInfoReaderFixture targetClassInfoReader = new TargetClassInfoReaderFixture(this.getClass().getClassLoader()); classReader.accept(targetClassInfoReader, 0); in.close(); Map<String, MethodSignatureVisitor> methodSignatures = targetClassInfoReader.getMethodSignatures(); return methodSignatures.values() .stream() .filter(msv -> { if (msv.getMethodName().equals("<init>")) { return false; } if (msv.getDeclaredClassName().startsWith(CLASS_SIGNATURE)) { return true; } return false; }) .findFirst().get(); } }
/** * Defines class name as a target. * Class will not be loaded by classloader! */ protected T setTarget(final String targetName) { assertTargetIsNotDefined(); try { targetInputStream = ClassLoaderUtil.getClassAsStream(targetName); if (targetInputStream == null) { throw new ProxettaException("Target class not found: " + targetName); } targetClassName = targetName; targetClass = null; } catch (IOException ioex) { StreamUtil.close(targetInputStream); throw new ProxettaException("Unable to get stream class name: " + targetName, ioex); } return _this(); }
@Test void testStream() throws IOException { InputStream is = ClassLoaderUtil.getClassAsStream(ClassLoaderUtilTest.class); assertNotNull(is); is.close(); is = ClassLoaderUtil.getClassAsStream(ClassLoaderUtilTest.class); assertNotNull(is); is.close(); URL url; final String resourceName = "jodd/util/Bits.class"; url = ClassLoaderUtil.getResourceUrl(resourceName); assertNotNull(url); is = ClassLoaderUtil.getResourceAsStream(resourceName); assertNotNull(is); is.close(); }
/** * Creates advice's class reader. */ private ClassReader createAdviceClassReader(Class<? extends ProxyAdvice> advice) { InputStream inputStream = null; try { inputStream = ClassLoaderUtil.getClassAsStream(advice); return new ClassReader(inputStream); } catch (IOException ioex) { throw new ProxettaException(ioex); } finally { StreamUtil.close(inputStream); } }
/** * Defines class as a target. */ protected void setTarget(Class target) { checkTarget(); try { targetInputStream = ClassLoaderUtil.getClassAsStream(target); targetClass = target; targetClassName = target.getName(); } catch (IOException ioex) { StreamUtil.close(targetInputStream); throw new ProxettaException("Unable to stream class: " + target.getName(), ioex); } }
ClassReader cr = null; try { inputStream = ClassLoaderUtil.getClassAsStream(nextSupername); cr = new ClassReader(inputStream); } catch (IOException ioex) { ClassReader cr = null; try { inputStream = ClassLoaderUtil.getClassAsStream(next); cr = new ClassReader(inputStream); } catch (IOException ioex) {
/** * Creates advice's class reader. */ private ClassReader createAdviceClassReader(final Class<? extends ProxyAdvice> advice) { InputStream inputStream = null; try { inputStream = ClassLoaderUtil.getClassAsStream(advice); return new ClassReader(inputStream); } catch (IOException ioex) { throw new ProxettaException(ioex); } finally { StreamUtil.close(inputStream); } }
/** * Defines class as a target. */ public T setTarget(final Class target) { assertTargetIsNotDefined(); try { targetInputStream = ClassLoaderUtil.getClassAsStream(target); if (targetInputStream == null) { throw new ProxettaException("Target class not found: " + target.getName()); } targetClass = target; targetClassName = target.getName(); } catch (IOException ioex) { StreamUtil.close(targetInputStream); throw new ProxettaException("Unable to stream class: " + target.getName(), ioex); } return _this(); }
/** * Defines class name as a target. * Class will not be loaded by classloader! */ protected void setTarget(String targetName) { checkTarget(); try { targetInputStream = ClassLoaderUtil.getClassAsStream(targetName); targetClassName = targetName; targetClass = null; } catch (IOException ioex) { StreamUtil.close(targetInputStream); throw new ProxettaException("Unable to stream class name: " + targetName, ioex); } }
stream = ClassLoaderUtil.getClassAsStream(declaringClass); } catch (IOException ioex) { throw new ParamoException("Unable to read class bytes: " + declaringClass.getName(), ioex);
inputStream = ClassLoaderUtil.getClassAsStream(nextSupername, classLoader); cr = new ClassReader(inputStream); } catch (IOException ioex) { ClassReader cr; try { inputStream = ClassLoaderUtil.getClassAsStream(next, classLoader); cr = new ClassReader(inputStream);
stream = ClassLoaderUtil.getClassAsStream(declaringClass); } catch (IOException ioex) { throw new ParamoException("Failed to read class bytes: " + declaringClass.getName(), ioex);
/** * Defines class name as a target. * Class will not be loaded by classloader! */ protected T setTarget(final String targetName) { assertTargetIsNotDefined(); try { targetInputStream = ClassLoaderUtil.getClassAsStream(targetName); if (targetInputStream == null) { throw new ProxettaException("Target class not found: " + targetName); } targetClassName = targetName; targetClass = null; } catch (IOException ioex) { StreamUtil.close(targetInputStream); throw new ProxettaException("Unable to get stream class name: " + targetName, ioex); } return _this(); }