Skip to content

Whether you can extend ASM ClassReader #34347

@fendo8888

Description

@fendo8888

I encrypted the jar. During the spring startup process, I will scan the class in the jar and read it through ClassReader. Finally, I found that there are two places that support obtaining the class from the jar, but the class at this time has not been decrypted, and will support error reporting

org.springframework.core.type.classreading.SimpleMetadataReader#getClassReader

	private static ClassReader getClassReader(Resource resource) throws IOException {
		try (InputStream is = resource.getInputStream()) {
			try {
				return new ClassReader(is);
			}
			catch (IllegalArgumentException ex) {
				throw new ClassFormatException("ASM ClassReader failed to parse class file - " +
						"probably due to a new Java class file version that is not supported yet. " +
						"Consider compiling with a lower '-target' or upgrade your framework version. " +
						"Affected class: " + resource, ex);
			}
		}
	}
org.springframework.asm.ClassReader.ClassReader(byte[],int,boolean)
org.springframework.cglib.core.AbstractClassGenerator.generate(ClassLoaderData)

How do I decrypt bytecode in a custom way before getClassReader?

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)status: duplicateA duplicate of another issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions