change to reflect

This commit is contained in:
Looly 2024-08-02 17:01:11 +08:00
parent fa45a775d9
commit e487d924cb
2 changed files with 68 additions and 45 deletions

View File

@ -15,7 +15,6 @@ package org.dromara.hutool.core.bean;
import org.dromara.hutool.core.annotation.AnnotationUtil; import org.dromara.hutool.core.annotation.AnnotationUtil;
import org.dromara.hutool.core.annotation.PropIgnore; import org.dromara.hutool.core.annotation.PropIgnore;
import org.dromara.hutool.core.convert.Convert; import org.dromara.hutool.core.convert.Convert;
import org.dromara.hutool.core.func.LambdaUtil;
import org.dromara.hutool.core.reflect.*; import org.dromara.hutool.core.reflect.*;
import org.dromara.hutool.core.reflect.method.MethodUtil; import org.dromara.hutool.core.reflect.method.MethodUtil;
@ -180,12 +179,9 @@ public class PropDesc {
*/ */
public Object getValue(final Object bean) { public Object getValue(final Object bean) {
if (null != this.getter) { if (null != this.getter) {
try{ // issue#3671 JDK15+ 修改了lambda的策略动态生成后在metaspace不会释放导致资源占用高
return LambdaUtil.buildGetter(this.getter).apply(bean); //return LambdaUtil.buildGetter(this.getter).apply(bean);
} catch (final Exception ignore){ return MethodUtil.invoke(bean, this.getter);
// issue#I96JIP在jdk14+多模块项目中存在权限问题使用传统反射
return MethodUtil.invoke(bean, this.getter);
}
} else if (ModifierUtil.isPublic(this.field)) { } else if (ModifierUtil.isPublic(this.field)) {
return FieldUtil.getFieldValue(bean, this.field); return FieldUtil.getFieldValue(bean, this.field);
} }

View File

@ -137,6 +137,7 @@ public class ZipUtil {
} }
} }
// region ----- zip
/** /**
* 打包到当前目录使用默认编码UTF-8 * 打包到当前目录使用默认编码UTF-8
* *
@ -428,7 +429,9 @@ public class ZipUtil {
return zipFile; return zipFile;
} }
// ---------------------------------------------------------------------------------------------- Unzip // endregion
// region ----- unzip
/** /**
* 解压到文件名相同的目录中默认编码UTF-8 * 解压到文件名相同的目录中默认编码UTF-8
@ -579,6 +582,47 @@ public class ZipUtil {
return outFile; return outFile;
} }
/**
* 解压<br>
* ZIP条目不使用高速缓冲
*
* @param in zip文件流使用完毕自动关闭
* @param outFile 解压到的目录
* @param charset 编码
* @return 解压的目录
* @throws HutoolException IO异常
* @since 4.5.8
*/
public static File unzip(final InputStream in, final File outFile, Charset charset) throws HutoolException {
if (null == charset) {
charset = DEFAULT_CHARSET;
}
return unzip(new ZipInputStream(in, charset), outFile);
}
/**
* 解压<br>
* ZIP条目不使用高速缓冲
*
* @param zipStream zip文件流包含编码信息
* @param outFile 解压到的目录
* @return 解压的目录
* @throws HutoolException IO异常
* @since 4.5.8
*/
public static File unzip(final ZipInputStream zipStream, final File outFile) throws HutoolException {
try (final ZipReader reader = new ZipReader(zipStream)) {
reader.readTo(outFile);
}
return outFile;
}
// endregion
// region ----- get and read
/** /**
* 获取压缩包中的指定文件流 * 获取压缩包中的指定文件流
* *
@ -621,41 +665,6 @@ public class ZipUtil {
} }
} }
/**
* 解压<br>
* ZIP条目不使用高速缓冲
*
* @param in zip文件流使用完毕自动关闭
* @param outFile 解压到的目录
* @param charset 编码
* @return 解压的目录
* @throws HutoolException IO异常
* @since 4.5.8
*/
public static File unzip(final InputStream in, final File outFile, Charset charset) throws HutoolException {
if (null == charset) {
charset = DEFAULT_CHARSET;
}
return unzip(new ZipInputStream(in, charset), outFile);
}
/**
* 解压<br>
* ZIP条目不使用高速缓冲
*
* @param zipStream zip文件流包含编码信息
* @param outFile 解压到的目录
* @return 解压的目录
* @throws HutoolException IO异常
* @since 4.5.8
*/
public static File unzip(final ZipInputStream zipStream, final File outFile) throws HutoolException {
try (final ZipReader reader = new ZipReader(zipStream)) {
reader.readTo(outFile);
}
return outFile;
}
/** /**
* 读取并处理Zip流中的每一个{@link ZipEntry} * 读取并处理Zip流中的每一个{@link ZipEntry}
* *
@ -669,6 +678,10 @@ public class ZipUtil {
} }
} }
// endregion
// region ----- unzipFileBytes
/** /**
* 从Zip文件中提取指定的文件为bytes * 从Zip文件中提取指定的文件为bytes
* *
@ -721,7 +734,9 @@ public class ZipUtil {
} }
} }
// ----------------------------------------------------------------------------- Gzip // endregion
// region ----- gzip
/** /**
* Gzip压缩处理 * Gzip压缩处理
@ -790,6 +805,10 @@ public class ZipUtil {
return bos.toByteArray(); return bos.toByteArray();
} }
// endregion
// region ----- unGzip
/** /**
* Gzip解压缩处理 * Gzip解压缩处理
* *
@ -839,7 +858,9 @@ public class ZipUtil {
return bos.toByteArray(); return bos.toByteArray();
} }
// ----------------------------------------------------------------------------- Zlib // endregion
// region ----- zlib
/** /**
* Zlib压缩处理 * Zlib压缩处理
@ -911,6 +932,10 @@ public class ZipUtil {
return out.toByteArray(); return out.toByteArray();
} }
// endregion
// region ----- unZlib
/** /**
* Zlib解压缩处理 * Zlib解压缩处理
* *
@ -959,6 +984,8 @@ public class ZipUtil {
return out.toByteArray(); return out.toByteArray();
} }
// endregion
/** /**
* 获取Zip文件中指定目录下的所有文件只显示文件不显示目录<br> * 获取Zip文件中指定目录下的所有文件只显示文件不显示目录<br>
* 此方法并不会关闭{@link ZipFile} * 此方法并不会关闭{@link ZipFile}