Releases: OxideWaveLength/Java-BetterReflection
HOTFIX: getCurrentJarFile(BetterReflectionClass)
Hotfix for BetterReflectionUtils#getCurrentJarFile(BetterReflectionClass), which now uses the given class parameter to determine whether it's running from Jar file or not.
1.3 Updated ClassFinder
ClassFinders:
Added an option to set the JarFile
Added an option to set the ClassLoader
This is useful when working with jar files loaded as modules. For example, Spigot plugins.
Fixed an issue where the IdeClassFinder wouldn't correctly find classes if the base package is empty.
Fixed UpToDate check, this will no longer say an update is available when the current version matches upstream.
1.2 - Added Dumpers
Additions
Created Dumper classes that are used to easily dump a Class, Constructor, Field or Method.
Fixes
Fixed missing generic in BetterReflectionClass#isAssignableFrom(BetterReflectionClass) method
Deprecation
Deprecated BetterReflectionUtils#dumpMethodHeader() and BetterReflectionUtils#generateMethodHeader()
1.1 - [API Change] Added generics, ClassFinder and Enums
API Change:
The BetterReflectionClass now uses generics to assign a class type
Enums:
Added support for enum classes through the EnumBetterReflectionClass, with the following methods
- #getEnumConstants()
- contains(String)
- getIfPresent(String)
- getOrNull(String)
- getOrDefault(String, T)
- toString(String)
- toString()
Added a ClassFinder: find and iterate through a java program's classes (both IDE runtime and packed jar)
This class deprecates BetterReflectionUtils#getClassesInPackage(String)
Added unit tests for the ClassFinder class
1.0 - [BREAKING] Package rename and maven central
The package has been renamed from me.wavelength.betterreflection
to top.wavelength.betterreflection
in order to be coherent with the domain used for Maven Central, where the library can now be found as follows
<dependency>
<groupId>top.wavelength</groupId>
<artifactId>Java-BetterReflection</artifactId>
<version>1.0</version>
</dependency>
0.7 - Fixed possible NPEs when detecting Jar File
There were some issues with the utility methods to retrieve the current jar file. They would sometimes return the incorrect value or throw exceptions. This release addresses such problems
0.6 - Caching class names
Now caching the various class names rather than retrieving them every time (it can make a big difference)
Fixed BetterReflectionClass#getSuperClass()
Commit: 1598623
0.5 - Fixed primitives
Made it so BetterReflection#PRIMITIVES are loaded in the static initialization of the class, removing the need to normally initialize the class at least once before being able to use them
Added some primitives to the map (short, byte and void)
BetterReflectionClass#getArrayClassIf(boolean), if the boolean passed in is true the class returned will be the same as #getArrayClass(), otherwise it will be the same as #getClasz()
0.4
These release notes come from this commit
BetterReflection:
- Added an int Pattern
- Added some primitives to the primitives map
- Added the method #getBetterReflectionClasses(), which will return a copy of the betterReflectionClasses list
- Added #getVersion(), which will return a hard-coded value that will be changed on each version
- Added #getLatestVersion(), which will query GitHub and return the latest version as a String
- Added #isUpToDate(), which will call #getLatestVersion() and #getVersion() to check if the current version is up to date
- Added #versionToInts(String), which will convert a String (e.g. "0.4") to an array of integers (such as { 0, 4 })
- Replaced the betterReflectionClasses CopyOnWriteArrayList with a simple synchronized ArrayList
BetterReflectionClass:
- Added the #forName() method, this will simply return #BetterReflectionClass(String) but return null if a ClassNotFoundException is to be thrown.
- #getName() - returns the class' name
- #getSimpleName() - returns the class' simple name
- #getCanonicalName() - returns the class' canonical name
- #getTypeName() - returns the class' type name
- Replaced BetterReflectionUtils#getClasses to BetterReflectionUtils#getTypes (renamed)
BetterReflectionUtils:
- Added a public static final File that holds the current jar file the program is being run from
- Added the method #getCurrentJarFile() which returns the current jar file the program is being run from (not cached, will be retrieved every time)
- Added the method #getCurrentJar() which returns the current jar File wrapped in a JarFile class
- Added the method #isRunningFromJar() which returns true if the program is running off of a jar, false if it's running in an IDE
- Added #getJavaVersion(), which will return the current java version as int
- Added #setFinal(Field field, boolean final), which will set a field to the desired final state (works in Java 12+ too but that'd require some additional JVM arguments)
- Fixed the class' content being pasted twice
- Renamed #getClasses(String) -> #getClassesInPackage(String), which returns a list of classes in the current package and now works both when running in an IDE and off of a jar, if the jar is still present
- Renamed #getClassByNameStart(String, String) -> #getClassesFromNameBeginning(String, String) (now works when running off a jar too)
- Removed #findClasses(File, String)
Tests:
- Now using nanoseconds instead of milliseconds
- Removed Timer class
Now also including sources in jar file, this way the javadocs will be accessible when using a good IDE.
Added some utilities
- #getDirectoriesFromPackageName(String packageName) - returns a file array of directories that match the package name
- #getClasses(String packageName) - returns an array of BetterReflectionClasses
- #findClasses(File directory, String packageName) - recursively return the classes in the directory and subdirectories
- #(String packageName, String start) - searches for classes starting with the string start and returns the first one as a BetterReflectionClass
None of the above methods adds the classes to the cache, you should manually add them to the BetterReflection's list