Skip to content

Commit

Permalink
Add missing javadoc.
Browse files Browse the repository at this point in the history
  • Loading branch information
raphw committed Sep 24, 2024
1 parent 4e920e3 commit da7f6d3
Showing 1 changed file with 22 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,7 @@ protected MultiReleaseAware(int[] version) {
public Resolution locate(String name) throws IOException {
String path = name.replace('.', File.separatorChar) + CLASS_FILE_EXTENSION;
for (int index = 0; index < version.length + 1; index++) {
byte[] binaryRepresentation = doLocate(index == version.length
? path
: MULTI_RELEASE_PREFIX + version[index] + "/" + path);
byte[] binaryRepresentation = doLocate(index == version.length ? path : MULTI_RELEASE_PREFIX + version[index] + "/" + path);
if (binaryRepresentation != null) {
return new Resolution.Explicit(binaryRepresentation);
}
Expand Down Expand Up @@ -329,9 +327,7 @@ public static ClassFileLocator ofResources(Map<String, byte[]> binaryRepresentat
*/
public Resolution locate(String name) {
byte[] binaryRepresentation = classFiles.get(name);
return binaryRepresentation == null
? new Resolution.Illegal(name)
: new Resolution.Explicit(binaryRepresentation);
return binaryRepresentation == null ? new Resolution.Illegal(name) : new Resolution.Explicit(binaryRepresentation);
}

/**
Expand Down Expand Up @@ -420,9 +416,7 @@ public static ClassFileLocator ofBootLoader() {
* @return A corresponding source locator.
*/
public static ClassFileLocator of(@MaybeNull ClassLoader classLoader) {
return new ForClassLoader(classLoader == null
? BOOT_LOADER_PROXY
: classLoader);
return new ForClassLoader(classLoader == null ? BOOT_LOADER_PROXY : classLoader);
}

/**
Expand All @@ -435,9 +429,7 @@ public static ClassFileLocator of(@MaybeNull ClassLoader classLoader) {
public static byte[] read(Class<?> type) {
try {
ClassLoader classLoader = type.getClassLoader();
return locate(classLoader == null
? BOOT_LOADER_PROXY
: classLoader, TypeDescription.ForLoadedType.getName(type)).resolve();
return locate(classLoader == null ? BOOT_LOADER_PROXY : classLoader, TypeDescription.ForLoadedType.getName(type)).resolve();
} catch (IOException exception) {
throw new IllegalStateException("Cannot read class file for " + type, exception);
}
Expand Down Expand Up @@ -586,19 +578,15 @@ protected WeaklyReferenced(ClassLoader classLoader) {
* @return A corresponding source locator.
*/
public static ClassFileLocator of(@MaybeNull ClassLoader classLoader) {
return classLoader == null || classLoader == ClassLoader.getSystemClassLoader() || classLoader == ClassLoader.getSystemClassLoader().getParent()
? ForClassLoader.of(classLoader)
: new WeaklyReferenced(classLoader);
return classLoader == null || classLoader == ClassLoader.getSystemClassLoader() || classLoader == ClassLoader.getSystemClassLoader().getParent() ? ForClassLoader.of(classLoader) : new WeaklyReferenced(classLoader);
}

/**
* {@inheritDoc}
*/
public Resolution locate(String name) throws IOException {
ClassLoader classLoader = get();
return classLoader == null
? new Resolution.Illegal(name)
: ForClassLoader.locate(classLoader, name);
return classLoader == null ? new Resolution.Illegal(name) : ForClassLoader.locate(classLoader, name);
}

/**
Expand Down Expand Up @@ -690,9 +678,7 @@ public static ClassFileLocator ofBootLayer() {
* @return An appropriate class file locator.
*/
public static ClassFileLocator of(JavaModule module) {
return module.isNamed()
? new ForModule(module)
: ForClassLoader.of(module.getClassLoader());
return module.isNamed() ? new ForModule(module) : ForClassLoader.of(module.getClassLoader());
}

/**
Expand Down Expand Up @@ -766,9 +752,7 @@ protected WeaklyReferenced(Object module) {
*/
public static ClassFileLocator of(JavaModule module) {
if (module.isNamed()) {
return module.getClassLoader() == null || module.getClassLoader() == ClassLoader.getSystemClassLoader() || module.getClassLoader() == ClassLoader.getSystemClassLoader().getParent()
? new ForModule(module)
: new WeaklyReferenced(module.unwrap());
return module.getClassLoader() == null || module.getClassLoader() == ClassLoader.getSystemClassLoader() || module.getClassLoader() == ClassLoader.getSystemClassLoader().getParent() ? new ForModule(module) : new WeaklyReferenced(module.unwrap());
} else {
return ForClassLoader.WeaklyReferenced.of(module.getClassLoader());
}
Expand All @@ -779,9 +763,7 @@ public static ClassFileLocator of(JavaModule module) {
*/
public Resolution locate(String name) throws IOException {
Object module = get();
return module == null
? new Resolution.Illegal(name)
: ForModule.locate(JavaModule.of(module), name);
return module == null ? new Resolution.Illegal(name) : ForModule.locate(JavaModule.of(module), name);
}

/**
Expand Down Expand Up @@ -921,9 +903,7 @@ private static ClassFileLocator of(JarFile jarFile, ClassFileVersion classFileVe
String name = enumeration.nextElement().getName();
if (name.endsWith(CLASS_FILE_EXTENSION) && name.startsWith(MultiReleaseAware.MULTI_RELEASE_PREFIX)) {
try {
int candidate = Integer.parseInt(name.substring(
MultiReleaseAware.MULTI_RELEASE_PREFIX.length(),
name.indexOf('/', MultiReleaseAware.MULTI_RELEASE_PREFIX.length())));
int candidate = Integer.parseInt(name.substring(MultiReleaseAware.MULTI_RELEASE_PREFIX.length(), name.indexOf('/', MultiReleaseAware.MULTI_RELEASE_PREFIX.length())));
if (candidate > 7 && candidate <= classFileVersion.getJavaVersion()) {
versions.add(candidate);
}
Expand Down Expand Up @@ -1121,9 +1101,7 @@ public static ClassFileLocator ofBootPath(File bootPath) throws IOException {
*/
public static ClassFileLocator ofModulePath() throws IOException {
String modulePath = System.getProperty("jdk.module.path");
return modulePath == null
? NoOp.INSTANCE
: ofModulePath(modulePath);
return modulePath == null ? NoOp.INSTANCE : ofModulePath(modulePath);
}

/**
Expand Down Expand Up @@ -1168,16 +1146,12 @@ public static ClassFileLocator ofModulePath(String modulePath, String baseFolder
if (aModule.isDirectory()) {
classFileLocators.add(ForFolder.of(aModule, classFileVersion));
} else if (aModule.isFile()) {
classFileLocators.add(aModule.getName().endsWith(JMOD_FILE_EXTENSION)
? of(aModule)
: ForJarFile.of(aModule, classFileVersion));
classFileLocators.add(aModule.getName().endsWith(JMOD_FILE_EXTENSION) ? of(aModule) : ForJarFile.of(aModule, classFileVersion));
}
}
}
} else if (file.isFile()) {
classFileLocators.add(file.getName().endsWith(JMOD_FILE_EXTENSION)
? of(file)
: ForJarFile.of(file));
classFileLocators.add(file.getName().endsWith(JMOD_FILE_EXTENSION) ? of(file) : ForJarFile.of(file));
}
}
return new Compound(classFileLocators);
Expand Down Expand Up @@ -1259,6 +1233,7 @@ protected ForFolder(int[] version, File folder) {
*
* @param folder The base folder of the package structure.
* @param classFileVersion The class file version to consider for multi-release JAR files.
* @return An appropriate class file locator.
* @throws IOException If an I/O exception occurs.
*/
public static ClassFileLocator of(File folder, ClassFileVersion classFileVersion) throws IOException {
Expand Down Expand Up @@ -1532,9 +1507,7 @@ public Resolution locate(String name) {
try {
DISPATCHER.retransformClasses(instrumentation, new Class<?>[]{classLoadingDelegate.locate(name)});
byte[] binaryRepresentation = classFileTransformer.getBinaryRepresentation();
return binaryRepresentation == null
? new Resolution.Illegal(name)
: new Resolution.Explicit(binaryRepresentation);
return binaryRepresentation == null ? new Resolution.Illegal(name) : new Resolution.Explicit(binaryRepresentation);
} finally {
instrumentation.removeTransformer(classFileTransformer);
}
Expand Down Expand Up @@ -1639,9 +1612,7 @@ protected Default(ClassLoader classLoader) {
* @return The class loading delegate for the provided class loader.
*/
public static ClassLoadingDelegate of(@MaybeNull ClassLoader classLoader) {
return ForDelegatingClassLoader.isDelegating(classLoader)
? new ForDelegatingClassLoader(classLoader)
: new Default(classLoader == null ? BOOT_LOADER_PROXY : classLoader);
return ForDelegatingClassLoader.isDelegating(classLoader) ? new ForDelegatingClassLoader(classLoader) : new Default(classLoader == null ? BOOT_LOADER_PROXY : classLoader);
}

/**
Expand All @@ -1656,9 +1627,7 @@ public Class<?> locate(String name) throws ClassNotFoundException {
*/
@MaybeNull
public ClassLoader getClassLoader() {
return classLoader == BOOT_LOADER_PROXY
? ClassLoadingStrategy.BOOTSTRAP_LOADER
: classLoader;
return classLoader == BOOT_LOADER_PROXY ? ClassLoadingStrategy.BOOTSTRAP_LOADER : classLoader;
}

/**
Expand Down Expand Up @@ -1746,9 +1715,7 @@ public Class<?> locate(String name) throws ClassNotFoundException {
return super.locate(name);
}
Class<?> type = classes.get(ONLY);
return TypeDescription.ForLoadedType.getName(type).equals(name)
? type
: super.locate(name);
return TypeDescription.ForLoadedType.getName(type).equals(name) ? type : super.locate(name);
}

/**
Expand Down Expand Up @@ -1949,9 +1916,7 @@ public static ClassLoadingDelegate of(Class<?> type) {
*/
public Class<?> locate(String name) throws ClassNotFoundException {
Class<?> type = types.get(name);
return type == null
? fallbackDelegate.locate(name)
: type;
return type == null ? fallbackDelegate.locate(name) : type;
}

/**
Expand Down Expand Up @@ -2009,11 +1974,7 @@ protected ExtractionClassFileTransformer(@MaybeNull ClassLoader classLoader, Str
*/
@MaybeNull
@SuppressFBWarnings(value = {"EI_EXPOSE_REP", "EI_EXPOSE_REP2"}, justification = "The array is not modified by class contract.")
public byte[] transform(@MaybeNull ClassLoader classLoader,
@MaybeNull String internalName,
@MaybeNull Class<?> redefinedType,
ProtectionDomain protectionDomain,
byte[] binaryRepresentation) {
public byte[] transform(@MaybeNull ClassLoader classLoader, @MaybeNull String internalName, @MaybeNull Class<?> redefinedType, ProtectionDomain protectionDomain, byte[] binaryRepresentation) {
if (internalName != null && isChildOf(this.classLoader).matches(classLoader) && typeName.equals(internalName.replace('/', '.'))) {
this.binaryRepresentation = binaryRepresentation.clone();
}
Expand Down Expand Up @@ -2059,12 +2020,8 @@ public PackageDiscriminating(Map<String, ClassFileLocator> classFileLocators) {
*/
public Resolution locate(String name) throws IOException {
int packageIndex = name.lastIndexOf('.');
ClassFileLocator classFileLocator = classFileLocators.get(packageIndex == -1
? NamedElement.EMPTY_NAME
: name.substring(0, packageIndex));
return classFileLocator == null
? new Resolution.Illegal(name)
: classFileLocator.locate(name);
ClassFileLocator classFileLocator = classFileLocators.get(packageIndex == -1 ? NamedElement.EMPTY_NAME : name.substring(0, packageIndex));
return classFileLocator == null ? new Resolution.Illegal(name) : classFileLocator.locate(name);
}

/**
Expand Down

0 comments on commit da7f6d3

Please sign in to comment.