This commit is contained in:
@@ -104,7 +104,7 @@ public class CacheSourceService implements CacheSource, Service {
|
|||||||
File store = new File(home, "cache/" + name());
|
File store = new File(home, "cache/" + name());
|
||||||
if (!store.isFile() || !store.canRead()) return;
|
if (!store.isFile() || !store.canRead()) return;
|
||||||
LineNumberReader reader = new LineNumberReader(new FileReader(store));
|
LineNumberReader reader = new LineNumberReader(new FileReader(store));
|
||||||
final Type storeType = TypeToken.createParameterizedType(CacheEntry.class, storeKeyType, storeValueType);
|
final Type storeType = TypeToken.createParameterizedType(null, CacheEntry.class, storeKeyType, storeValueType);
|
||||||
String line;
|
String line;
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
if (line.isEmpty()) continue;
|
if (line.isEmpty()) continue;
|
||||||
@@ -132,7 +132,7 @@ public class CacheSourceService implements CacheSource, Service {
|
|||||||
store.getParentFile().mkdirs();
|
store.getParentFile().mkdirs();
|
||||||
PrintStream stream = new PrintStream(store, "UTF-8");
|
PrintStream stream = new PrintStream(store, "UTF-8");
|
||||||
Collection<CacheEntry> values = container.values();
|
Collection<CacheEntry> values = container.values();
|
||||||
final Type storeType = TypeToken.createParameterizedType(CacheEntry.class, storeKeyType, storeValueType);;
|
final Type storeType = TypeToken.createParameterizedType(null, CacheEntry.class, storeKeyType, storeValueType);;
|
||||||
for (CacheEntry entry : values) {
|
for (CacheEntry entry : values) {
|
||||||
stream.println(convert.convertTo(storeType, entry));
|
stream.println(convert.convertTo(storeType, entry));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public abstract class TypeToken<T> {
|
|||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Type createParameterizedType(final Class rawType, final Class... actualTypeArguments) {
|
public static Type createParameterizedType(final Type ownerType, final Type rawType, final Type... actualTypeArguments) {
|
||||||
ClassLoader loader = TypeToken.class.getClassLoader();
|
ClassLoader loader = TypeToken.class.getClassLoader();
|
||||||
String newDynName = TypeToken.class.getName().replace('.', '/') + "_Dyn" + System.currentTimeMillis();
|
String newDynName = TypeToken.class.getName().replace('.', '/') + "_Dyn" + System.currentTimeMillis();
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@@ -44,11 +44,11 @@ public abstract class TypeToken<T> {
|
|||||||
FieldVisitor fv;
|
FieldVisitor fv;
|
||||||
MethodVisitor mv;
|
MethodVisitor mv;
|
||||||
cw.visit(V1_8, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, newDynName, null, "java/lang/Object", null);
|
cw.visit(V1_8, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, newDynName, null, "java/lang/Object", null);
|
||||||
String rawTypeDesc = jdk.internal.org.objectweb.asm.Type.getDescriptor(rawType);
|
String rawTypeDesc = jdk.internal.org.objectweb.asm.Type.getDescriptor((Class) rawType);
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append(rawTypeDesc.substring(0, rawTypeDesc.length() - 1)).append('<');
|
sb.append(rawTypeDesc.substring(0, rawTypeDesc.length() - 1)).append('<');
|
||||||
for (Class c : actualTypeArguments) {
|
for (Type c : actualTypeArguments) {
|
||||||
sb.append(jdk.internal.org.objectweb.asm.Type.getDescriptor(c));
|
sb.append(jdk.internal.org.objectweb.asm.Type.getDescriptor((Class) c));
|
||||||
}
|
}
|
||||||
sb.append(">;");
|
sb.append(">;");
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user