Skip to content

Commit

Permalink
Renamed variables for exceptions from "e" to "exception" in order to …
Browse files Browse the repository at this point in the history
…remove abbreviations in the code to make the code base better readable.
  • Loading branch information
Rafael Winterhalter committed Aug 6, 2015
1 parent 92be204 commit b8d02fb
Show file tree
Hide file tree
Showing 29 changed files with 134 additions and 108 deletions.
Expand Up @@ -172,9 +172,9 @@ public static Instrumentation installOnOpenJDK() {
} }
try { try {
doInstall(); doInstall();
} catch (Exception e) { } catch (Exception exception) {
throw new IllegalStateException("The programmatic installation of the Byte Buddy agent is only " + throw new IllegalStateException("The programmatic installation of the Byte Buddy agent is only " +
"possible on the OpenJDK and JDKs with a compatible 'tools.jar'", e); "possible on the OpenJDK and JDKs with a compatible 'tools.jar'", exception);
} }
return getInstrumentation(); return getInstrumentation();
} }
Expand Down Expand Up @@ -279,8 +279,8 @@ private static Instrumentation doGetInstrumentation() {
.getDeclaredField(INSTRUMENTATION_FIELD_NAME); .getDeclaredField(INSTRUMENTATION_FIELD_NAME);
field.setAccessible(true); field.setAccessible(true);
return (Instrumentation) field.get(STATIC_MEMBER); return (Instrumentation) field.get(STATIC_MEMBER);
} catch (Exception e) { } catch (Exception exception) {
throw new IllegalStateException("The Byte Buddy agent is not properly initialized", e); throw new IllegalStateException("The Byte Buddy agent is not properly initialized", exception);
} }
} }


Expand Down
Expand Up @@ -66,8 +66,8 @@ public void testConstructorThrowsException() throws Exception {
try { try {
constructor.newInstance(); constructor.newInstance();
fail(); fail();
} catch (InvocationTargetException e) { } catch (InvocationTargetException exception) {
throw (Exception) e.getCause(); throw (Exception) exception.getCause();
} }
} }
} }
Expand Up @@ -60,8 +60,8 @@ public void testConstructorThrowsException() throws Exception {
try { try {
constructor.newInstance(); constructor.newInstance();
fail(); fail();
} catch (InvocationTargetException e) { } catch (InvocationTargetException exception) {
throw (Exception) e.getCause(); throw (Exception) exception.getCause();
} }
} }
} }
Expand Up @@ -134,13 +134,13 @@ public Map<TypeDescription, Class<?>> load(ClassLoader classLoader, Map<TypeDesc
for (TypeDescription typeDescription : types.keySet()) { for (TypeDescription typeDescription : types.keySet()) {
try { try {
loadedTypes.put(typeDescription, dexClassLoader.loadClass(typeDescription.getName())); loadedTypes.put(typeDescription, dexClassLoader.loadClass(typeDescription.getName()));
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException exception) {
throw new IllegalStateException("Cannot load " + typeDescription, e); throw new IllegalStateException("Cannot load " + typeDescription, exception);
} }
} }
return loadedTypes; return loadedTypes;
} catch (IOException e) { } catch (IOException exception) {
throw new IllegalStateException("Cannot write to zip file " + zipFile, e); throw new IllegalStateException("Cannot write to zip file " + zipFile, exception);
} finally { } finally {
if (!zipFile.delete()) { if (!zipFile.delete()) {
Logger.getAnonymousLogger().warning("Could not delete " + zipFile); Logger.getAnonymousLogger().warning("Could not delete " + zipFile);
Expand Down
Expand Up @@ -6,6 +6,7 @@
import net.bytebuddy.ByteBuddy; import net.bytebuddy.ByteBuddy;
import net.bytebuddy.benchmark.specimen.ExampleClass; import net.bytebuddy.benchmark.specimen.ExampleClass;
import net.bytebuddy.dynamic.loading.ClassLoadingStrategy; import net.bytebuddy.dynamic.loading.ClassLoadingStrategy;
import net.bytebuddy.dynamic.loading.PackageDefiner;
import net.bytebuddy.implementation.MethodDelegation; import net.bytebuddy.implementation.MethodDelegation;
import net.bytebuddy.implementation.SuperMethodCall; import net.bytebuddy.implementation.SuperMethodCall;
import net.bytebuddy.implementation.bind.annotation.RuntimeType; import net.bytebuddy.implementation.bind.annotation.RuntimeType;
Expand Down Expand Up @@ -79,7 +80,7 @@ public ExampleClass benchmarkByteBuddyWithAnnotations() throws Exception {
.subclass(baseClass) .subclass(baseClass)
.method(isDeclaredBy(ExampleClass.class)).intercept(MethodDelegation.to(ByteBuddyInterceptor.class)) .method(isDeclaredBy(ExampleClass.class)).intercept(MethodDelegation.to(ByteBuddyInterceptor.class))
.make() .make()
.load(newClassLoader(), ClassLoadingStrategy.Default.INJECTION) .load(newClassLoader(), ClassLoadingStrategy.Default.INJECTION.withPackageDefiner(PackageDefiner.NoOp.INSTANCE))
.getLoaded() .getLoaded()
.newInstance(); .newInstance();
} }
Expand All @@ -98,7 +99,7 @@ public ExampleClass benchmarkByteBuddySpecialized() throws Exception {
.subclass(baseClass) .subclass(baseClass)
.method(isDeclaredBy(ExampleClass.class)).intercept(SuperMethodCall.INSTANCE) .method(isDeclaredBy(ExampleClass.class)).intercept(SuperMethodCall.INSTANCE)
.make() .make()
.load(newClassLoader(), ClassLoadingStrategy.Default.INJECTION) .load(newClassLoader(), ClassLoadingStrategy.Default.INJECTION.withPackageDefiner(PackageDefiner.NoOp.INSTANCE))
.getLoaded() .getLoaded()
.newInstance(); .newInstance();
} }
Expand Down
Expand Up @@ -6,6 +6,7 @@
import net.bytebuddy.ByteBuddy; import net.bytebuddy.ByteBuddy;
import net.bytebuddy.benchmark.specimen.ExampleInterface; import net.bytebuddy.benchmark.specimen.ExampleInterface;
import net.bytebuddy.dynamic.loading.ClassLoadingStrategy; import net.bytebuddy.dynamic.loading.ClassLoadingStrategy;
import net.bytebuddy.dynamic.loading.PackageDefiner;
import net.bytebuddy.implementation.StubMethod; import net.bytebuddy.implementation.StubMethod;
import net.sf.cglib.proxy.CallbackHelper; import net.sf.cglib.proxy.CallbackHelper;
import net.sf.cglib.proxy.Enhancer; import net.sf.cglib.proxy.Enhancer;
Expand Down Expand Up @@ -170,7 +171,7 @@ public ExampleInterface benchmarkByteBuddy() throws Exception {
.subclass(baseClass) .subclass(baseClass)
.method(isDeclaredBy(baseClass)).intercept(StubMethod.INSTANCE) .method(isDeclaredBy(baseClass)).intercept(StubMethod.INSTANCE)
.make() .make()
.load(newClassLoader(), ClassLoadingStrategy.Default.INJECTION) .load(newClassLoader(), ClassLoadingStrategy.Default.INJECTION.withPackageDefiner(PackageDefiner.NoOp.INSTANCE))
.getLoaded() .getLoaded()
.newInstance(); .newInstance();
} }
Expand Down
Expand Up @@ -16,8 +16,8 @@ public void testCannotInstantiateClass() throws Exception {
try { try {
constructor.newInstance(); constructor.newInstance();
fail(); fail();
} catch (InvocationTargetException e) { } catch (InvocationTargetException exception) {
throw (UnsupportedOperationException) e.getCause(); throw (UnsupportedOperationException) exception.getCause();
} }
} }
} }
Expand Up @@ -6,6 +6,7 @@
import net.bytebuddy.dynamic.ClassFileLocator; import net.bytebuddy.dynamic.ClassFileLocator;
import net.bytebuddy.dynamic.DynamicType; import net.bytebuddy.dynamic.DynamicType;
import net.bytebuddy.dynamic.loading.ClassInjector; import net.bytebuddy.dynamic.loading.ClassInjector;
import net.bytebuddy.dynamic.loading.PackageDefiner;
import net.bytebuddy.dynamic.scaffold.InstrumentedType; import net.bytebuddy.dynamic.scaffold.InstrumentedType;
import net.bytebuddy.dynamic.scaffold.inline.MethodRebaseResolver; import net.bytebuddy.dynamic.scaffold.inline.MethodRebaseResolver;
import net.bytebuddy.implementation.Implementation; import net.bytebuddy.implementation.Implementation;
Expand Down Expand Up @@ -960,8 +961,8 @@ public ClassFileTransformer installOnByteBuddyAgent() {
.loadClass(BYTE_BUDDY_AGENT_TYPE) .loadClass(BYTE_BUDDY_AGENT_TYPE)
.getDeclaredMethod(GET_INSTRUMENTATION_METHOD) .getDeclaredMethod(GET_INSTRUMENTATION_METHOD)
.invoke(STATIC_METHOD)); .invoke(STATIC_METHOD));
} catch (Exception e) { } catch (Exception exception) {
throw new IllegalStateException("The Byte Buddy agent is not installed or not accessible", e); throw new IllegalStateException("The Byte Buddy agent is not installed or not accessible", exception);
} }
} }


Expand Down Expand Up @@ -1310,8 +1311,8 @@ protected enum Accessor {
.filter(named("getDeclaredMethod").and(takesArguments(String.class, Class[].class))).getOnly(); .filter(named("getDeclaredMethod").and(takesArguments(String.class, Class[].class))).getOnly();
invokeMethod = new TypeDescription.ForLoadedType(Method.class).getDeclaredMethods() invokeMethod = new TypeDescription.ForLoadedType(Method.class).getDeclaredMethods()
.filter(named("invoke").and(takesArguments(Object.class, Object[].class))).getOnly(); .filter(named("invoke").and(takesArguments(Object.class, Object[].class))).getOnly();
} catch (Exception e) { } catch (Exception exception) {
throw new IllegalStateException("Cannot create type initialization accessor", e); throw new IllegalStateException("Cannot create type initialization accessor", exception);
} }
} }


Expand All @@ -1325,10 +1326,10 @@ protected enum Accessor {
public void register(String name, ClassLoader classLoader, Object typeInitializer) { public void register(String name, ClassLoader classLoader, Object typeInitializer) {
try { try {
registration.invoke(STATIC_METHOD, name, classLoader, typeInitializer); registration.invoke(STATIC_METHOD, name, classLoader, typeInitializer);
} catch (IllegalAccessException e) { } catch (IllegalAccessException exception) {
throw new IllegalStateException("Cannot register type initializer for " + name, e); throw new IllegalStateException("Cannot register type initializer for " + name, exception);
} catch (InvocationTargetException e) { } catch (InvocationTargetException exception) {
throw new IllegalStateException("Cannot register type initializer for " + name, e.getCause()); throw new IllegalStateException("Cannot register type initializer for " + name, exception.getCause());
} }
} }


Expand Down Expand Up @@ -1567,7 +1568,7 @@ public byte[] transform(ClassLoader classLoader,
if (loadedTypeInitializers.size() > 1) { if (loadedTypeInitializers.size() > 1) {
ClassInjector classInjector = classLoader == null ClassInjector classInjector = classLoader == null
? bootstrapInjectionStrategy.make(protectionDomain) ? bootstrapInjectionStrategy.make(protectionDomain)
: new ClassInjector.UsingReflection(classLoader, protectionDomain); : new ClassInjector.UsingReflection(classLoader, protectionDomain, PackageDefiner.NoOp.INSTANCE);
for (Map.Entry<TypeDescription, Class<?>> auxiliary : classInjector.inject(dynamicType.getRawAuxiliaryTypes()).entrySet()) { for (Map.Entry<TypeDescription, Class<?>> auxiliary : classInjector.inject(dynamicType.getRawAuxiliaryTypes()).entrySet()) {
initializationStrategy.initialize(auxiliary.getValue(), loadedTypeInitializers.get(auxiliary.getKey())); initializationStrategy.initialize(auxiliary.getValue(), loadedTypeInitializers.get(auxiliary.getKey()));
} }
Expand Down
Expand Up @@ -1258,7 +1258,7 @@ private boolean equalsRepresentation(Object self, Object other) {
.equals(entry.getValue().resolve(), entry.getKey().invoke(other))) { .equals(entry.getValue().resolve(), entry.getKey().invoke(other))) {
return false; return false;
} }
} catch (RuntimeException e) { } catch (RuntimeException exception) {
return false; // Incomplete annotations are not equal to one another. return false; // Incomplete annotations are not equal to one another.
} }
} else { } else {
Expand All @@ -1267,8 +1267,8 @@ private boolean equalsRepresentation(Object self, Object other) {
} }
} catch (InvocationTargetException ignored) { } catch (InvocationTargetException ignored) {
return false; return false;
} catch (IllegalAccessException e) { } catch (IllegalAccessException exception) {
throw new AssertionError(e); throw new AssertionError(exception);
} }
return true; return true;
} }
Expand Down Expand Up @@ -1513,17 +1513,17 @@ public abstract static class ForPrepared<S extends Annotation> extends AbstractB
public S loadSilent() { public S loadSilent() {
try { try {
return load(); return load();
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException exception) {
throw new IllegalStateException(ERROR_MESSAGE, e); throw new IllegalStateException(ERROR_MESSAGE, exception);
} }
} }


@Override @Override
public S loadSilent(ClassLoader classLoader) { public S loadSilent(ClassLoader classLoader) {
try { try {
return load(classLoader); return load(classLoader);
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException exception) {
throw new IllegalStateException(ERROR_MESSAGE, e); throw new IllegalStateException(ERROR_MESSAGE, exception);
} }
} }
} }
Expand Down Expand Up @@ -1632,8 +1632,8 @@ public Object getValue(MethodDescription methodDescription) {
} }
} }
return describe(method.invoke(annotation), methodDescription.getReturnType().asRawType()); return describe(method.invoke(annotation), methodDescription.getReturnType().asRawType());
} catch (Exception e) { } catch (Exception exception) {
throw new IllegalStateException("Cannot access annotation property " + methodDescription, e); throw new IllegalStateException("Cannot access annotation property " + methodDescription, exception);
} }
} }


Expand Down
Expand Up @@ -716,7 +716,9 @@ public String getCanonicalName() {
@Override @Override
public String getSimpleName() { public String getSimpleName() {
int simpleNameIndex = getInternalName().lastIndexOf('$'); int simpleNameIndex = getInternalName().lastIndexOf('$');
simpleNameIndex = simpleNameIndex == -1 ? getInternalName().lastIndexOf('/') : simpleNameIndex; simpleNameIndex = simpleNameIndex == -1
? getInternalName().lastIndexOf('/')
: simpleNameIndex;
return simpleNameIndex == -1 ? getInternalName() : getInternalName().substring(simpleNameIndex + 1); return simpleNameIndex == -1 ? getInternalName() : getInternalName().substring(simpleNameIndex + 1);
} }


Expand Down
Expand Up @@ -114,8 +114,8 @@ public static Resolution of(Class<?> type) {
} else { } else {
try { try {
return new Explicit(new StreamDrainer().drain(inputStream)); return new Explicit(new StreamDrainer().drain(inputStream));
} catch (IOException e) { } catch (IOException exception) {
throw new IllegalStateException(e); throw new IllegalStateException(exception);
} }
} }
} }
Expand Down Expand Up @@ -407,8 +407,8 @@ public static ClassFileLocator fromInstalledAgent(ClassLoader classLoader) {
.loadClass(BYTE_BUDDY_AGENT_TYPE) .loadClass(BYTE_BUDDY_AGENT_TYPE)
.getDeclaredMethod(GET_INSTRUMENTATION_METHOD) .getDeclaredMethod(GET_INSTRUMENTATION_METHOD)
.invoke(STATIC_METHOD), classLoader); .invoke(STATIC_METHOD), classLoader);
} catch (Exception e) { } catch (Exception exception) {
throw new IllegalStateException("The Byte Buddy agent is not installed or not accessible", e); throw new IllegalStateException("The Byte Buddy agent is not installed or not accessible", exception);
} }
} }


Expand Down Expand Up @@ -564,8 +564,8 @@ class ForDelegatingClassLoader extends Default {
Field field = ClassLoader.class.getDeclaredField("classes"); Field field = ClassLoader.class.getDeclaredField("classes");
field.setAccessible(true); field.setAccessible(true);
classesField = new JavaField.ForResolvedField(field); classesField = new JavaField.ForResolvedField(field);
} catch (Exception e) { } catch (Exception exception) {
classesField = new JavaField.ForNonResolvedField(e); classesField = new JavaField.ForNonResolvedField(exception);
} }
CLASSES_FIELD = classesField; CLASSES_FIELD = classesField;
} }
Expand Down
Expand Up @@ -2296,8 +2296,8 @@ public byte[] create(Implementation.Context.ExtractableView implementationContex
throw new IllegalArgumentException("Cannot locate the class file for " + targetType + " using " + classFileLocator); throw new IllegalArgumentException("Cannot locate the class file for " + targetType + " using " + classFileLocator);
} }
return doCreate(implementationContext, resolution.resolve()); return doCreate(implementationContext, resolution.resolve());
} catch (IOException e) { } catch (IOException exception) {
throw new RuntimeException("The class file could not be written", e); throw new RuntimeException("The class file could not be written", exception);
} }
} }


Expand Down
Expand Up @@ -126,10 +126,10 @@ public void onLoad(Class<?> type) {
field.setAccessible(true); field.setAccessible(true);
} }
field.set(STATIC_FIELD, value); field.set(STATIC_FIELD, value);
} catch (IllegalAccessException e) { } catch (IllegalAccessException exception) {
throw new IllegalArgumentException("Cannot access " + fieldName + " from " + type, e); throw new IllegalArgumentException("Cannot access " + fieldName + " from " + type, exception);
} catch (NoSuchFieldException e) { } catch (NoSuchFieldException exception) {
throw new IllegalStateException("There is no field " + fieldName + " defined on " + type, e); throw new IllegalStateException("There is no field " + fieldName + " defined on " + type, exception);
} }
} }


Expand Down
12 changes: 6 additions & 6 deletions byte-buddy-dep/src/main/java/net/bytebuddy/pool/TypePool.java
Expand Up @@ -969,8 +969,8 @@ protected Resolution doDescribe(String name) {
return resolution.isResolved() return resolution.isResolved()
? new Resolution.Simple(parse(resolution.resolve())) ? new Resolution.Simple(parse(resolution.resolve()))
: new Resolution.Illegal(name); : new Resolution.Illegal(name);
} catch (IOException e) { } catch (IOException exception) {
throw new IllegalStateException("Error while reading class file", e); throw new IllegalStateException("Error while reading class file", exception);
} }
} }


Expand Down Expand Up @@ -5251,17 +5251,17 @@ public S load(ClassLoader classLoader) throws ClassNotFoundException {
public S loadSilent() { public S loadSilent() {
try { try {
return load(); return load();
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException exception) {
throw new IllegalStateException(ForLoadedAnnotation.ERROR_MESSAGE, e); throw new IllegalStateException(ForLoadedAnnotation.ERROR_MESSAGE, exception);
} }
} }


@Override @Override
public S loadSilent(ClassLoader classLoader) { public S loadSilent(ClassLoader classLoader) {
try { try {
return load(classLoader); return load(classLoader);
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException exception) {
throw new IllegalStateException(ForLoadedAnnotation.ERROR_MESSAGE, e); throw new IllegalStateException(ForLoadedAnnotation.ERROR_MESSAGE, exception);
} }
} }
} }
Expand Down
20 changes: 10 additions & 10 deletions byte-buddy-dep/src/main/java/net/bytebuddy/utility/JavaMethod.java
Expand Up @@ -94,10 +94,10 @@ public boolean isInvokable() {
public Object invoke(Object instance, Object... argument) { public Object invoke(Object instance, Object... argument) {
try { try {
return method.invoke(instance, argument); return method.invoke(instance, argument);
} catch (IllegalAccessException e) { } catch (IllegalAccessException exception) {
throw new IllegalStateException("Cannot invoke dynamically-linked method", e); throw new IllegalStateException("Cannot invoke dynamically-linked method", exception);
} catch (InvocationTargetException e) { } catch (InvocationTargetException exception) {
throw new IllegalStateException("Exception when invoking method", e.getCause()); throw new IllegalStateException("Exception when invoking method", exception.getCause());
} }
} }


Expand Down Expand Up @@ -158,12 +158,12 @@ public Object invoke(Object instance, Object... argument) {
public Object invokeStatic(Object... argument) { public Object invokeStatic(Object... argument) {
try { try {
return constructor.newInstance(argument); return constructor.newInstance(argument);
} catch (InstantiationException e) { } catch (InstantiationException exception) {
throw new IllegalStateException("Cannot initiate class", e); throw new IllegalStateException("Cannot initiate class", exception);
} catch (IllegalAccessException e) { } catch (IllegalAccessException exception) {
throw new IllegalStateException("Cannot invoke dynamically-linked method", e); throw new IllegalStateException("Cannot invoke dynamically-linked method", exception);
} catch (InvocationTargetException e) { } catch (InvocationTargetException exception) {
throw new IllegalStateException("Exception when invoking method", e.getCause()); throw new IllegalStateException("Exception when invoking method", exception.getCause());
} }
} }


Expand Down
Expand Up @@ -776,8 +776,8 @@ class LoggingMemoryDatabase extends MemoryDatabase {
public List<String> load(String info) { public List<String> load(String info) {
try { try {
return LoggerInterceptor.log(new LoadMethodSuperCall(info)); return LoggerInterceptor.log(new LoadMethodSuperCall(info));
} catch (Exception e) { } catch (Exception exception) {
throw new RuntimeException(e); throw new RuntimeException(exception);
} }
} }


Expand Down

0 comments on commit b8d02fb

Please sign in to comment.