增加AsmDepends

This commit is contained in:
redkale
2023-08-13 22:27:11 +08:00
parent 5ed7bc2c6f
commit 87892b27e7
8 changed files with 55 additions and 1 deletions

View File

@@ -5,9 +5,10 @@
*/
package org.redkale.annotation;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.*;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import org.redkale.asm.AsmDepends;
/**
* 类似java.beans.ConstructorProperties, 必须配合Creator使用
@@ -20,6 +21,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Documented
@Target({METHOD, CONSTRUCTOR})
@Retention(RUNTIME)
@AsmDepends
public @interface ConstructorParameters {
String[] value();

View File

@@ -0,0 +1,25 @@
/*
*
*/
package org.redkale.asm;
import java.lang.annotation.*;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
/**
* 被标记的元素表示会被asm动态字节码调用到
*
* <p>
* 详情见: https://redkale.org
*
*
* @author zhangjx
* @since 2.8.0
*/
@Documented
@Target({TYPE, METHOD, FIELD})
@Retention(SOURCE)
public @interface AsmDepends {
}

View File

@@ -6,6 +6,7 @@
package org.redkale.convert;
import java.lang.reflect.Type;
import org.redkale.asm.AsmDepends;
/**
* 反序列化操作类
@@ -17,6 +18,7 @@ import java.lang.reflect.Type;
* @param <R> Reader输入的子类
* @param <T> 反解析的数据类型
*/
@AsmDepends
public interface Decodeable<R extends Reader, T> {
/**

View File

@@ -6,6 +6,7 @@
package org.redkale.convert;
import java.lang.reflect.Type;
import org.redkale.asm.AsmDepends;
/**
* 序列化操作类
@@ -17,6 +18,7 @@ import java.lang.reflect.Type;
* @param <W> Writer输出的子类
* @param <T> 序列化的数据类型
*/
@AsmDepends
public interface Encodeable<W extends Writer, T> {
/**

View File

@@ -7,6 +7,7 @@ package org.redkale.convert;
import java.lang.reflect.*;
import java.util.function.*;
import org.redkale.asm.AsmDepends;
import org.redkale.util.*;
/**
@@ -118,6 +119,7 @@ public abstract class Writer {
*
* @param clazz 对象的类名
*/
@AsmDepends
public final void writeObjectNull(final Class clazz) {
writeClassName(null);
writeNull();

View File

@@ -6,6 +6,7 @@
package org.redkale.convert.json;
import java.lang.reflect.Type;
import org.redkale.asm.AsmDepends;
import org.redkale.convert.*;
/**
@@ -34,6 +35,7 @@ public abstract class JsonWriter extends Writer {
return this;
}
@AsmDepends
public boolean isExtFuncEmpty() {
return this.objExtFunc == null && this.objFieldFunc == null;
}
@@ -63,42 +65,57 @@ public abstract class JsonWriter extends Writer {
* @param quote 是否加双引号
* @param value 非null且不含需要转义的字符的String值
*/
@AsmDepends
public abstract void writeLatin1To(final boolean quote, final String value);
@AsmDepends
public abstract void writeFieldShortValue(final byte[] fieldBytes, final short value);
@AsmDepends
public abstract void writeFieldIntValue(final byte[] fieldBytes, final int value);
@AsmDepends
public abstract void writeFieldLongValue(final byte[] fieldBytes, final long value);
@AsmDepends
public abstract void writeFieldLatin1Value(final byte[] fieldBytes, final String value);
@AsmDepends
public abstract void writeLastFieldShortValue(final byte[] fieldBytes, final short value);
@AsmDepends
public abstract void writeLastFieldIntValue(final byte[] fieldBytes, final int value);
@AsmDepends
public abstract void writeLastFieldLongValue(final byte[] fieldBytes, final long value);
@AsmDepends
public abstract void writeLastFieldLatin1Value(final byte[] fieldBytes, final String value);
//firstFieldBytes 必须带{开头
@AsmDepends
public abstract void writeObjectByOnlyOneLatin1FieldValue(final byte[] firstFieldBytes, final String value);
//firstFieldBytes 必须带{开头, lastFieldBytes必须,开头
@AsmDepends
public abstract void writeObjectByOnlyTwoIntFieldValue(final byte[] firstFieldBytes, final int value1, final byte[] lastFieldBytes, final int value2);
@Override
@AsmDepends
public abstract void writeBoolean(boolean value);
@Override
@AsmDepends
public abstract void writeInt(int value);
@Override
@AsmDepends
public abstract void writeLong(long value);
public abstract void writeString(final boolean quote, String value);
@Override
@AsmDepends
public abstract void writeString(String value);
@Override //只容许JsonBytesWriter重写此方法

View File

@@ -8,6 +8,7 @@ package org.redkale.net.sncp;
import java.lang.reflect.Type;
import java.nio.channels.CompletionHandler;
import java.util.concurrent.*;
import org.redkale.asm.AsmDepends;
import org.redkale.convert.bson.BsonWriter;
import org.redkale.net.Response;
import org.redkale.util.ByteArray;
@@ -82,6 +83,7 @@ public class SncpResponse extends Response<SncpContext, SncpRequest> {
return this;
}
@AsmDepends
public <T extends CompletionHandler> T getParamAsyncHandler() {
return (T) this.paramAsyncHandler;
}

View File

@@ -24,6 +24,7 @@ import java.util.stream.Stream;
import java.util.zip.GZIPInputStream;
import javax.crypto.*;
import javax.crypto.spec.SecretKeySpec;
import org.redkale.asm.AsmDepends;
import org.redkale.convert.json.JsonConvert;
/**
@@ -2741,6 +2742,7 @@ public final class Utility {
*
* @return 对象
*/
@AsmDepends
public static <T> T convertValue(Type type, Object value) {
if (type == null || value == null) {
return (T) value;