INNER CODE UNIT · Java

stubify

anggrayudi/android-hidden-api · cli/Stubifier.java:69

    public static byte[] stubify(byte[] in) {
        ClassReader cr = new ClassReader(in);
        ClassNode cn = new ClassNode();
        cr.accept(cn, ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);
        if (cn.methods != null) {
            for (MethodNode mn : cn.methods) {
                // Abstract/native methods have no Code attribute — nothing to strip.
                if ((mn.access & (Opcodes.ACC_ABSTRACT | Opcodes.ACC_NATIVE)) != 0) continue;
                stubMethod(cn, mn);
            }
        }
        // COMPUTE_MAXS is enough: the stub body is straight-line (no branches/frames), so ASM
        // never needs getCommonSuperClass (which would try — and fail — to load framework classes).
        ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
        cn.accept(cw);
        return cw.toByteArray();
    }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…