Search in sources :

Example 1 with SKIP_FRAMES

use of org.apache.xbean.asm9.ClassReader.SKIP_FRAMES in project component-runtime by Talend.

the class ProxyGenerator method findJavaVersion.

private int findJavaVersion(final Class<?> from) {
    final String resource = from.getName().replace('.', '/') + ".class";
    try (final InputStream stream = from.getClassLoader().getResourceAsStream(resource)) {
        if (stream == null) {
            return javaVersion;
        }
        final ClassReader reader = new ClassReader(stream);
        final VersionVisitor visitor = new VersionVisitor();
        reader.accept(visitor, SKIP_DEBUG + SKIP_CODE + SKIP_FRAMES);
        if (visitor.version != 0) {
            return visitor.version;
        }
    } catch (final Exception e) {
    // no-op
    }
    // version
    return javaVersion;
}
Also used : InputStream(java.io.InputStream) ClassReader(org.apache.xbean.asm9.ClassReader) ObjectStreamException(java.io.ObjectStreamException)

Aggregations

InputStream (java.io.InputStream)1 ObjectStreamException (java.io.ObjectStreamException)1 ClassReader (org.apache.xbean.asm9.ClassReader)1