Search in sources :

Example 1 with SKIP_DEBUG

use of org.apache.xbean.asm6.ClassReader.SKIP_DEBUG 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);
        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.asm6.ClassReader) ObjectStreamException(java.io.ObjectStreamException)

Aggregations

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