Opcodes.ASM5 and visitModule

Cédric Champeau <[email protected]> Wed, 5 Jul 2017 17:46:46 +0200
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <CADQzvm=+EAR10pVvga+2-t1bKyf=UuJyhB+=kUx_2aG-n_K=Tw@mail.gmail.com>
Hi folks,

I have a question regarding the API of ASM 6, and how to use it properly.
For Gradle, we do what we call "compile classpath snapshotting", which is
basically computing an ABI signature for all classes (if a dependency
changes, and that its ABI didn't change, we don't need to recompile). For
that, of course, we use ASM 5. So far, we used a patched `ClassReader`
which blindly accepted the Java 9 format version, and visited the classes
with Opcodes.ASM5.

Then, I faced some mocking issues [1], which turned out to be solved if I
upgraded to ASM 6 alpha. So far so good, I tried it, but then lots of tests
started to fail with:

*Malformed jar [asm-all-6.0_ALPHA.jar] found on classpath. Gradle 5.0 will
no longer allow malformed jars on a classpath.*

which is an error message coming from our compile classpath snapshotting.
Ironically, the ASM 6 jar wouldn't be analyzable with ASM 6! I switched to
the debug version of ASM which gave me a little more insight: it failed on
`visitModule`, which, I suspected, was related to our snapshotter visiting
the module-info file in asm6 jar.

And indeed, here's the sources:

    public ModuleVisitor visitModule() {
        if (api < Opcodes.ASM6) {
            throw new RuntimeException();
        }
        if (cv != null) {
            return cv.visitModule();
        }
        return null;
    }

Then my question is, given that I started visiting with ASM5, which didn't
know about modules, shouldn't it just *ignore* visitModule and return null,
instead of failing? If not, then it would be a good idea to provide a
better error message.

As a side note, I need to figure out what parts of a module descriptor we
should consider relevant to the ABI signature.

[1] https://github.com/cglib/cglib/issues/106

Thanks,
Cédric


-- 
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws