throw new IllegalClassFormatException("Unable to mark " + convertedClassName + " as transformed.");
private static String getClassName(byte[] bytecode) throws IllegalClassFormatException { try { return new ClassReader(bytecode).getClassName(); } catch (Throwable t) { /* If the class file contains errors, ASM will just crash. */ IllegalClassFormatException e = new IllegalClassFormatException(); e.initCause(t); throw e; } } }
throw new ClassNotFoundException(icfEx.toString(), icfEx);
private byte[] doTransform(final String resourceName, final byte[] inBytes) { if (transformers.isEmpty()) { return inBytes; } byte[] bytes = inBytes; for (final ClassFileTransformer transformer : transformers) { try { bytes = transformer.transform(this, resourceName, null, null, bytes); } catch (final IllegalClassFormatException e) { log.error(e.getMessage() + ", will ignore the transformers", e); break; } } return bytes; }
/** * Instruments the specified class with debug information. */ @Requires("bytecode != null") @Ensures("result != null") public byte[] transformWithDebug(byte[] bytecode) throws IllegalClassFormatException { try { return instrumentWithDebug(bytecode); } catch (Throwable t) { /* If the class file contains errors, ASM will just crash. */ IllegalClassFormatException e = new IllegalClassFormatException(); e.initCause(t); throw e; } }
throw new ClassNotFoundException(icfEx.toString(), icfEx);
public byte[] preprocess(String resourceName, byte[] classBytes) { try { // convert java/lang/Object.class to java/lang/Object String classname = resourceName.substring(0, resourceName.length() - 6); // ".class" size = 6 byte[] newBytes = transformer.transform( cl, classname, null, null, classBytes); // ClassFileTransformer returns null if no transformation // took place, where as ByteCodePreprocessor is expected // to return non-null byte array. return newBytes == null ? classBytes : newBytes; } catch (IllegalClassFormatException e) { logger.logp(Level.WARNING, "WebModuleListener$InstrumentableClassLoader$BytecodePreprocessor", "preprocess", e.getMessage()); throw new RuntimeException(e); } } });
@Override public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { // Lambdas and anonymous methods in Java 8 do not have a class name defined and so no transformation should be done if (className == null || StringUtils.isBlank(getTargetedClass()) || StringUtils.isBlank(getTableName())) { return null; } byte[] classBytes = null; String convertedClassName = className.replace('/', '.'); if (convertedClassName.equalsIgnoreCase(getTargetedClass())) { try { String targetValue = getTableName(); if (LOG.isDebugEnabled()) { LOG.debug("Altering " + convertedClassName + " table name"); } ClassFile classFile = new ClassFile(new DataInputStream(new ByteArrayInputStream(classfileBuffer))); ConstPool constantPool = classFile.getConstPool(); alterTableAnnotation(classFile, targetValue, constantPool); ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream os = new DataOutputStream(bos); classFile.write(os); os.close(); classBytes = bos.toByteArray(); } catch (Exception ex) { ex.printStackTrace(); throw new IllegalClassFormatException("Unable to convert " + convertedClassName + " to a SingleTable inheritance strategy: " + ex.getMessage()); } } return classBytes; }
/** * Instruments the specified class with contracts. */ @Requires({ "bytecode != null", "contractBytecode != null" }) @Ensures("result != null") public byte[] transformWithContracts(byte[] bytecode, byte[] contractBytecode) throws IllegalClassFormatException { try { ContractAnalyzer contracts = extractContracts(new ClassReader(contractBytecode)); return instrumentWithContracts(bytecode, contracts); } catch (Throwable t) { /* If the class file contains errors, ASM will just crash. */ IllegalClassFormatException e = new IllegalClassFormatException(); e.initCause(t); throw e; } }
throw new ClassNotFoundException(icfEx.toString(), icfEx);
} catch (Exception e) { e.printStackTrace(); throw new IllegalClassFormatException("Unable to convert " + convertedClassName + " to a SingleTable inheritance strategy: " + e.getMessage());
log(SessionLog.SEVERE, e); IllegalClassFormatException ex = new IllegalClassFormatException(); ex.initCause(e); throw ex;
throw new IllegalClassFormatException("Unable to convert " + convertedClassName + " to sandbox: " + ex.getMessage());
cf = ClassFile.readFrom(new ByteArrayInputStream(classfileBuffer)); } catch (Exception e) { IllegalClassFormatException e2 = new IllegalClassFormatException(); e2.initCause(e); throw e2; out.close(); } catch (Exception e) { IllegalClassFormatException e2 = new IllegalClassFormatException(); e2.initCause(e); throw e2;
} catch(Exception ex) { ex.printStackTrace(); throw new IllegalClassFormatException("Unable to convert " + convertedClassName + " to a SingleTable inheritance strategy: " + ex.getMessage());
public byte[] transform( ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer ) throws IllegalClassFormatException { try { return classTransformer.transform( loader, className, classBeingRedefined, protectionDomain, classfileBuffer ); } catch (Exception e) { throw new IllegalClassFormatException( e.getMessage() ); } } }
public byte[] transform( ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer ) throws IllegalClassFormatException { try { return classTransformer.transform( loader, className, classBeingRedefined, protectionDomain, classfileBuffer ); } catch (Exception e) { throw new IllegalClassFormatException( e.getMessage() ); } } }
public byte[] transform( ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer ) throws IllegalClassFormatException { try { return classTransformer.transform( loader, className, classBeingRedefined, protectionDomain, classfileBuffer ); } catch (Exception e) { throw new IllegalClassFormatException( e.getMessage() ); } } }
throw new IllegalClassFormatException(e.getMessage());
@Override public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { try { if (className.contains("com/ibm/wala") || className.contains("java/lang") || (className.contains("java/") && !className.matches("java/util/[A-Z]")) || className.contains("sun/")) { return classfileBuffer; } else { ClassInstrumenter ci = new ClassInstrumenter(className, classfileBuffer, cha); return OfflineDynamicCallGraph.doClass(ci, out).makeBytes(); } } catch (InvalidClassFileException | IOException | FailureException e) { e.printStackTrace(); System.err.println("got here with " + e.getMessage()); throw new IllegalClassFormatException(e.getMessage()); } }