Class JavaClassfileVersion
- java.lang.Object
-
- org.codehaus.plexus.languages.java.version.JavaClassfileVersion
-
public final class JavaClassfileVersion extends java.lang.ObjectReads the bytecode of a Java class to detect the major, minor and Java version that was compiled.- Author:
- Jorge Solórzano
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)inthashCode()booleanisPreview()Returns if the classfile use preview features.JavaVersionjavaVersion()JavaVersion of the class file version detected.intmajorVersion()Returns the major version of the parsed classfile.intminorVersion()Returns the minor version of the parsed classfile.static JavaClassfileVersionof(byte[] bytes)Reads the bytecode of a Java class file and returns theJavaClassfileVersion.static JavaClassfileVersionof(java.nio.file.Path path)Reads the bytecode of a Java class file and returns theJavaClassfileVersion.java.lang.StringtoString()Returns a String representation of the Java class file version, e.g.
-
-
-
Method Detail
-
of
public static JavaClassfileVersion of(byte[] bytes)
Reads the bytecode of a Java class file and returns theJavaClassfileVersion.- Parameters:
bytes-byte[]of the Java class file- Returns:
- the
JavaClassfileVersionof the byte array
-
of
public static JavaClassfileVersion of(java.nio.file.Path path)
Reads the bytecode of a Java class file and returns theJavaClassfileVersion.- Parameters:
path-Pathof the Java class file- Returns:
- the
JavaClassfileVersionof the path java class
-
javaVersion
public JavaVersion javaVersion()
JavaVersion of the class file version detected.- Returns:
- JavaVersion based on the major version of the class file.
-
majorVersion
public int majorVersion()
Returns the major version of the parsed classfile.- Returns:
- the major classfile version
-
minorVersion
public int minorVersion()
Returns the minor version of the parsed classfile.- Returns:
- the minor classfile version
-
isPreview
public boolean isPreview()
Returns if the classfile use preview features.- Returns:
trueif the classfile use preview features.
-
toString
public java.lang.String toString()
Returns a String representation of the Java class file version, e.g.65.0 (Java 21).- Overrides:
toStringin classjava.lang.Object- Returns:
- String representation of the Java class file version
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
-