Skip to content

Commit 1be726a

Browse files
committed
Add class for instance bindings if it's not whitelisted.
1 parent 2606937 commit 1be726a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

modules/lang-painless/src/main/java/org/elasticsearch/painless/lookup/PainlessLookupBuilder.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,6 +1050,14 @@ public void addPainlessInstanceBinding(Object targetInstance, String methodName,
10501050
}
10511051

10521052
String targetCanonicalClassName = typeToCanonicalTypeName(targetClass);
1053+
Class<?> existingTargetClass = javaClassNamesToClasses.get(targetClass.getName());
1054+
1055+
if (existingTargetClass == null) {
1056+
javaClassNamesToClasses.put(targetClass.getName(), targetClass);
1057+
} else if (existingTargetClass != targetClass) {
1058+
throw new IllegalArgumentException("class [" + targetCanonicalClassName + "] " +
1059+
"cannot represent multiple java classes with the same name from different class loaders");
1060+
}
10531061

10541062
if (METHOD_NAME_PATTERN.matcher(methodName).matches() == false) {
10551063
throw new IllegalArgumentException(

0 commit comments

Comments
 (0)