Skip to content

Commit

Permalink
Merge pull request mvel#201 from MalcolmOdd/Issue200
Browse files Browse the repository at this point in the history
Fix IncompatibleClassChangeError for bean property accessor declared in interface
  • Loading branch information
mariofusco authored Dec 16, 2019
2 parents dacf9e5 + f0b39f1 commit 56b8415
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1117,9 +1117,16 @@ else if (member != null) {

returnType = ((Method) member).getReturnType();

assert debug("INVOKEVIRTUAL " + member.getName() + ":" + returnType);
mv.visitMethodInsn(INVOKEVIRTUAL, getInternalName(member.getDeclaringClass()), member.getName(),
if (member.getDeclaringClass().isInterface()) {
assert debug("INVOKEINTERFACE " + member.getName() + ":" + returnType);
mv.visitMethodInsn(INVOKEINTERFACE, getInternalName(member.getDeclaringClass()), member.getName(),
getMethodDescriptor((Method) member));
}
else {
assert debug("INVOKEVIRTUAL " + member.getName() + ":" + returnType);
mv.visitMethodInsn(INVOKEVIRTUAL, getInternalName(member.getDeclaringClass()), member.getName(),
getMethodDescriptor((Method) member));
}
}
catch (IllegalAccessException e) {
Method iFaceMeth = determineActualTargetMethod((Method) member);
Expand Down
16 changes: 16 additions & 0 deletions src/test/java/org/mvel2/tests/core/PropertyAccessTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -548,4 +548,20 @@ public void testNullListMapArrayValueMVEL312(){
public void testPublicStaticFieldMVEL314(){
assertEquals(Foo.STATIC_BAR, runSingleTest("org.mvel2.tests.core.res.Foo.STATIC_BAR"));
}
/*
* Test fix for https://github.com/mvel/mvel/issues/200
*/
public void testCollectionEmptyASM() {
Serializable compiled = MVEL.compileExpression("validationIssues.empty");
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("validationIssues", new ArrayList<Object>());
int trueCount = 0;
final int COUNT = 1000;
for (int i = 0; i < COUNT; i++) {
if (MVEL.executeExpression(compiled, properties, Boolean.class)) {
trueCount++;
}
}
assertEquals(COUNT, trueCount);
}
}

0 comments on commit 56b8415

Please sign in to comment.