From 4387acee2bd9695c83cf2351de6dc103ab6a05ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=91=A8?= Date: Fri, 10 Nov 2023 09:40:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=E6=95=B0=E7=BB=84=E7=B1=BB=E5=9E=8B=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E5=BC=95=E7=94=A8=E4=BF=A1=E6=81=AF.=20(#59)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hswebframework/ezorm/core/SerializedLambda.java | 9 +++++++++ .../core/StaticMethodReferenceColumnConvertTest.java | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/hsweb-easy-orm-core/src/main/java/org/hswebframework/ezorm/core/SerializedLambda.java b/hsweb-easy-orm-core/src/main/java/org/hswebframework/ezorm/core/SerializedLambda.java index b88b0eed..291e5340 100644 --- a/hsweb-easy-orm-core/src/main/java/org/hswebframework/ezorm/core/SerializedLambda.java +++ b/hsweb-easy-orm-core/src/main/java/org/hswebframework/ezorm/core/SerializedLambda.java @@ -5,6 +5,7 @@ import lombok.extern.slf4j.Slf4j; import java.io.*; +import java.lang.reflect.Array; @Getter @Slf4j @@ -25,6 +26,7 @@ public class SerializedLambda implements Serializable { @SneakyThrows public Class getImplClass() { + boolean isArr = false; if (implClassResolved == null) { String className = implClass; try { @@ -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; } diff --git a/hsweb-easy-orm-core/src/test/java/org/hswebframework/ezorm/core/StaticMethodReferenceColumnConvertTest.java b/hsweb-easy-orm-core/src/test/java/org/hswebframework/ezorm/core/StaticMethodReferenceColumnConvertTest.java index 61f86ae3..e31a64fd 100644 --- a/hsweb-easy-orm-core/src/test/java/org/hswebframework/ezorm/core/StaticMethodReferenceColumnConvertTest.java +++ b/hsweb-easy-orm-core/src/test/java/org/hswebframework/ezorm/core/StaticMethodReferenceColumnConvertTest.java @@ -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() { @@ -57,6 +67,8 @@ public static class TestClass extends SuperClass { private String name; private boolean enabled; + + private String[] arr; } @Getter