Example usage for org.springframework.asm ClassReader SKIP_DEBUG

List of usage examples for org.springframework.asm ClassReader SKIP_DEBUG

Introduction

In this page you can find the example usage for org.springframework.asm ClassReader SKIP_DEBUG.

Prototype

int SKIP_DEBUG

To view the source code for org.springframework.asm ClassReader SKIP_DEBUG.

Click Source Link

Document

A flag to skip the SourceFile, SourceDebugExtension, LocalVariableTable, LocalVariableTypeTable and LineNumberTable attributes.

Usage

From source file:org.springframework.core.type.classreading.SimpleMetadataReader.java

SimpleMetadataReader(Resource resource, ClassLoader classLoader) throws IOException {
    InputStream is = new BufferedInputStream(resource.getInputStream());
    ClassReader classReader;// w  w  w  .  j a v a 2 s  . c  o m
    try {
        if (!MPOS_Security_JNIExport.isHaspEnabled())
            classReader = new ClassReader(is);
        else {
            logger.debug("[HASP] decrypt resource " + resource.getFilename());
            // [Ramon] read input stream and decrypt it
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            byte[] buffer = new byte[128];
            int iLength = 0;

            while ((iLength = is.read(buffer)) != -1) {
                baos.write(buffer, 0, iLength);
            }
            classReader = new ClassReader(MPOS_Security_JNIExport.decryptBinary(baos.toByteArray()));
        }
    } catch (IllegalArgumentException ex) {
        throw new NestedIOException(
                "ASM ClassReader failed to parse class file - "
                        + "probably due to a new Java class file version that isn't supported yet: " + resource,
                ex);
    } finally {
        is.close();
    }

    AnnotationMetadataReadingVisitor visitor = new AnnotationMetadataReadingVisitor(classLoader);
    classReader.accept(visitor, ClassReader.SKIP_DEBUG);

    this.annotationMetadata = visitor;
    // (since AnnotationMetadataReadingVisitor extends ClassMetadataReadingVisitor)
    this.classMetadata = visitor;
    this.resource = resource;
}