Refactor method name dispatching to switch statements
This commit refactors method name dispatching to switch statements in WebSphereClassPreDefinePlugin. Closes gh-25170
This commit is contained in:
parent
2a5fc08629
commit
2549674f41
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -61,21 +61,17 @@ class WebSphereClassPreDefinePlugin implements InvocationHandler {
|
|||
|
||||
@Override
|
||||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||||
String name = method.getName();
|
||||
if ("equals".equals(name)) {
|
||||
return (proxy == args[0]);
|
||||
}
|
||||
else if ("hashCode".equals(name)) {
|
||||
return hashCode();
|
||||
}
|
||||
else if ("toString".equals(name)) {
|
||||
return toString();
|
||||
}
|
||||
else if ("transformClass".equals(name)) {
|
||||
return transform((String) args[0], (byte[]) args[1], (CodeSource) args[2], (ClassLoader) args[3]);
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("Unknown method: " + method);
|
||||
switch (method.getName()) {
|
||||
case "equals":
|
||||
return (proxy == args[0]);
|
||||
case "hashCode":
|
||||
return hashCode();
|
||||
case "toString":
|
||||
return toString();
|
||||
case "transformClass":
|
||||
return transform((String) args[0], (byte[]) args[1], (CodeSource) args[2], (ClassLoader) args[3]);
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown method: " + method);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue