@Test public void test1() throws Throwable { ComputeClassWriter computeClassWriter0 = new ComputeClassWriter(2147483632); String string0 = computeClassWriter0.getCommonSuperClass("java/lang/String", "java/lang/Object"); assertEquals("java/lang/Object", string0); }
ClassReader info2; try { info1 = typeInfo(type1); } catch (NullPointerException e) { info2 = typeInfo(type2); } catch (NullPointerException e) { if (typeImplements(type2, info2, type1)) { return type1; if (typeImplements(type1, info1, type2)) { return type2; if (typeImplements(type1, info1, type2)) { return type2; } else { StringBuilder b1 = typeAncestors(type1, info1); StringBuilder b2 = typeAncestors(type2, info2); String result = "java/lang/Object"; int end1 = b1.length();
if (typeImplements(itfs[i], typeInfo(itfs[i]), itf)) { return true; info = typeInfo(type);
@Override protected byte[] getTransformedBytes( String className, InputStream is) throws IOException{ ClassReader reader = new ClassReader(is); int readFlags = ClassReader.SKIP_FRAMES; /* * To use COMPUTE_FRAMES we need to remove JSR commands. * Therefore, we have a JSRInlinerAdapter in NonTargetClassAdapter * as well as CFGAdapter. */ int asmFlags = ClassWriter.COMPUTE_FRAMES; ClassWriter writer = new ComputeClassWriter(asmFlags); ClassVisitor cv = writer; cv = new NonTargetClassAdapter(cv, className); reader.accept(cv, readFlags); return writer.toByteArray(); } }
/** * Returns the internal names of the ancestor classes of the given type. * * @param type * the internal name of a class or interface. * @param info * the ClassReader corresponding to 'type'. * @return a StringBuilder containing the ancestor classes of 'type', * separated by ';'. The returned string has the following format: * ";type1;type2 ... ;typeN", where type1 is 'type', and typeN is a * direct subclass of Object. If 'type' is Object, the returned * string is empty. * @throws IOException * if the bytecode of 'type' or of some of its ancestor class * cannot be loaded. */ private StringBuilder typeAncestors(String type, ClassReader info) throws IOException { StringBuilder b = new StringBuilder(); while (!"java/lang/Object".equals(type)) { b.append(';').append(type); type = info.getSuperName(); info = typeInfo(type); } return b; }
ClassWriter writer = new ComputeClassWriter(asmFlags);
@Test public void test3() throws Throwable { ComputeClassWriter computeClassWriter0 = new ComputeClassWriter((-2878)); String string0 = computeClassWriter0.getCommonSuperClass("java/lang/Throwable", "java/lang/Throwable"); assertEquals("java/lang/Throwable", string0); }
ClassWriter writer = new ComputeClassWriter(asmFlags);
@Test public void test0() throws Throwable { ComputeClassWriter computeClassWriter0 = new ComputeClassWriter((-2878)); String string0 = computeClassWriter0.getCommonSuperClass("java/lang/Class", "java/lang/Throwable"); assertEquals("java/lang/Object", string0); }
@Test public void test2() throws Throwable { ComputeClassWriter computeClassWriter0 = new ComputeClassWriter((-2878)); // Undeclared exception! try { computeClassWriter0.getCommonSuperClass("java/lang/Throwable", ""); fail("Expecting exception: RuntimeException"); } catch(RuntimeException e) { // // Class not found: : shaded.org.evosuite.runtime.mock.java.lang.MockThrowable: Class not found // assertThrownBy("org.evosuite.runtime.util.ComputeClassWriter", e); } }
@Test public void test4() throws Throwable { ComputeClassWriter computeClassWriter0 = new ComputeClassWriter((-32768)); // Undeclared exception! try { computeClassWriter0.getCommonSuperClass("", "37SFrh2"); fail("Expecting exception: RuntimeException"); } catch(RuntimeException e) { // // Class not found: : shaded.org.evosuite.runtime.mock.java.lang.MockThrowable: Class not found // assertThrownBy("org.evosuite.runtime.util.ComputeClassWriter", e); } } }