解决子类代理遇到数组参数报错的问题.
This commit is contained in:
+10
-2
@@ -28,7 +28,6 @@ import lombok.experimental.Accessors;
|
||||
import org.apache.velocity.Template;
|
||||
import org.apache.velocity.VelocityContext;
|
||||
import org.apache.velocity.app.VelocityEngine;
|
||||
import sun.management.MethodInfo;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -144,9 +143,18 @@ public class AsgcProxyGenerator {
|
||||
* @param clazz
|
||||
*/
|
||||
private synchronized void appendImport(List<Class<?>> importClasses, Class<?> clazz) {
|
||||
if (importClasses.contains(clazz) || clazz.getName().startsWith("java.lang.") || TypeUtil.isNormalBasicType(clazz) || clazz == void.class) {
|
||||
if (importClasses.contains(clazz) ||
|
||||
clazz.getName().startsWith("java.lang.") ||
|
||||
TypeUtil.isNormalBasicType(clazz) ||
|
||||
clazz == void.class
|
||||
) {
|
||||
return;
|
||||
}
|
||||
if (clazz.isArray()) {
|
||||
appendImport(importClasses, clazz.getComponentType());
|
||||
return;
|
||||
}
|
||||
|
||||
importClasses.add(clazz);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,4 +37,10 @@ public class AsgcProxyGeneratorTest {
|
||||
System.out.println(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2() {
|
||||
String result = AsgcProxyGenerator.getInstance().generator("A", Giraffe.class);
|
||||
System.out.println(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Copyright (c) 2022 aoshiguchen
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package fun.asgc.neutrino.core.aop;
|
||||
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author: aoshiguchen
|
||||
* @date: 2022/7/6
|
||||
*/
|
||||
public class Giraffe {
|
||||
public void run(String[] args) {
|
||||
System.out.println("运行:" + Arrays.toString(args));
|
||||
}
|
||||
|
||||
public Dog getDog() {
|
||||
return new Dog();
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ import java.util.Set;
|
||||
* @author: aoshiguchen
|
||||
* @date: 2022/7/4
|
||||
*/
|
||||
@NonIntercept(false)
|
||||
@NeutrinoApplication
|
||||
public class Launcher {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user