Skip to content

Commit

Permalink
fix: 修复无法解析数组类型方法引用信息. (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhou-hao authored Nov 10, 2023
1 parent ae2e00f commit 4387ace
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.extern.slf4j.Slf4j;

import java.io.*;
import java.lang.reflect.Array;

@Getter
@Slf4j
Expand All @@ -25,6 +26,7 @@ public class SerializedLambda implements Serializable {

@SneakyThrows
public Class<?> getImplClass() {
boolean isArr = false;
if (implClassResolved == null) {
String className = implClass;
try {
Expand All @@ -33,11 +35,18 @@ public Class<?> getImplClass() {
if (!type.startsWith("L")) {
className = type;
}
if (className.startsWith("[L")) {
className = className.substring(2);
isArr = true;
}
} catch (Throwable ignore) {

}
implClassResolved = Class.forName(className.replace('/', '.'));
}
if(isArr){
return Array.newInstance(implClassResolved,0).getClass();
}
return implClassResolved;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ public void testConvertLambdaColumn() {

}


@Test
public void testArr(){
TestClass testClass = new TestClass();

Assert.assertEquals(MethodReferenceConverter.convertToColumn(testClass::getArr), "arr");
Assert.assertEquals(MethodReferenceConverter.convertToColumn(TestClass::getArr), "arr");

}

@Test
public void testSuper() {

Expand All @@ -57,6 +67,8 @@ public static class TestClass extends SuperClass {
private String name;

private boolean enabled;

private String[] arr;
}

@Getter
Expand Down

0 comments on commit 4387ace

Please sign in to comment.