Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

Java library that reads in the class file bytes and provides metadata without having to load the class.

License

Notifications You must be signed in to change notification settings

j256/simpleclassreader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sSimple Java Class Reader

Maven Central javadoc ChangeLog CodeCov CircleCI GitHub License

library that allows you to read class bytes and see all of the class metadata without loading the class which might cause a large amount of class loading from imports. There are a number of times you might want to do this if you wanted to interrogate a class to make sure that it has certain annotations or qualities before incurring the cost of loading it with the ClassLoader.

This is based on the Java class format documentation.

Enjoy. Gray Watson

Quick Example:

Read in a class from a file.

String path = "target/classes/path/to/classfile.class";
CsvProcessor<Account> csvProcessor = new CsvProcessor<Account>(Account.class);
try (InputStream fis = new FileInputStream(path);) {
	ClassInfo info = ClassReader.readClass(fis);
	System.out.println("Class name is " + info.getName());
	System.out.println("Fields: " + Arrays.toString(info.getFields());
	System.out.println("Constructors: " + Arrays.toString(info.getConstructors());
	System.out.println("Methods: " + Arrays.toString(info.getMethods());
}

Maven Configuration

Maven packages are published via Maven Central

<dependency>
	<groupId>com.j256.simpleclassreader</groupId>
	<artifactId>simpleclassreader</artifactId>
	<version>0.4</version>
</dependency>

ChangeLog Release Notes

See the ChangeLog.txt file.

About

Java library that reads in the class file bytes and provides metadata without having to load the class.

Resources

License

Stars

Watchers

Forks

Packages

No packages published