Skip to content

Commit e632d89

Browse files
committed
Depend on iText snapshot. Remove redundant methods from ReflectionUtils
DEVSIX-4170
1 parent 878f609 commit e632d89

1 file changed

Lines changed: 0 additions & 62 deletions

File tree

pdfocr-tesseract4/src/main/java/com/itextpdf/pdfocr/tesseract4/ReflectionUtils.java

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,6 @@ final class ReflectionUtils {
5858
private static Map<String, Class<?>> cachedClasses = new HashMap<>();
5959
private static Map<MethodSignature, AccessibleObject> cachedMethods = new HashMap<>();
6060

61-
static {
62-
try {
63-
ContextManager contextManager = ContextManager.getInstance();
64-
callMethod(KERNEL_PACKAGE + CONTEXT_MANAGER, REGISTER_GENERIC_CONTEXT, contextManager,
65-
new Class[] {Collection.class, Collection.class},
66-
Collections.singletonList("com.itextpdf.pdfocr"),
67-
Collections.singletonList("com.itextpdf.pdfocr.tesseract4"));
68-
callMethod(KERNEL_PACKAGE + CONTEXT_MANAGER, REGISTER_GENERIC_CONTEXT, contextManager,
69-
new Class[] {Collection.class, Collection.class},
70-
Collections.singletonList("com.itextpdf.pdfocr.tesseract4"),
71-
Collections.singletonList("com.itextpdf.pdfocr.tesseract4"));
72-
} catch (Exception e) {
73-
logger.error(e.getMessage());
74-
}
75-
}
76-
7761
private ReflectionUtils() {
7862
}
7963

@@ -116,52 +100,6 @@ public static void scheduledCheck() {
116100
}
117101
}
118102

119-
private static Object callMethod(String className, String methodName, Object target, Class[] parameterTypes,
120-
Object... args) {
121-
try {
122-
Method method = findMethod(className, methodName, parameterTypes);
123-
return method.invoke(target, args);
124-
} catch (NoSuchMethodException e) {
125-
logger.warn(MessageFormatUtil.format("Cannot find method {0} for class {1}", methodName, className));
126-
} catch (ClassNotFoundException e) {
127-
logger.warn(MessageFormatUtil.format("Cannot find class {0}", className));
128-
} catch (IllegalArgumentException e) {
129-
logger.warn(MessageFormatUtil
130-
.format("Illegal arguments passed to {0}#{1} method call: {2}", className, methodName,
131-
e.getMessage()));
132-
} catch (Exception e) {
133-
// Converting checked exceptions to unchecked RuntimeException (java-specific comment).
134-
//
135-
// If kernel utils throws an exception at this point, we consider it as unrecoverable situation for
136-
// its callers (pdfOcr methods).
137-
// It's might be more suitable to wrap checked exceptions at a bit higher level, but we do it here for
138-
// the sake of convenience.
139-
throw new RuntimeException(e.toString(), e);
140-
}
141-
return null;
142-
}
143-
144-
private static Method findMethod(String className, String methodName, Class[] parameterTypes)
145-
throws NoSuchMethodException, ClassNotFoundException {
146-
MethodSignature tm = new MethodSignature(className, parameterTypes, methodName);
147-
Method m = (Method) cachedMethods.get(tm);
148-
if (m == null) {
149-
m = findClass(className).getDeclaredMethod(methodName, parameterTypes);
150-
m.setAccessible(true);
151-
cachedMethods.put(tm, m);
152-
}
153-
return m;
154-
}
155-
156-
private static Class<?> findClass(String className) throws ClassNotFoundException {
157-
Class<?> c = cachedClasses.get(className);
158-
if (c == null) {
159-
c = getClass(className);
160-
cachedClasses.put(className, c);
161-
}
162-
return c;
163-
}
164-
165103
private static Class<?> getClass(String className) throws ClassNotFoundException {
166104
return Class.forName(className);
167105
}

0 commit comments

Comments
 (0)