This commit is contained in:
wentch
2015-12-18 11:36:09 +08:00
parent 6b5eb3d545
commit 2973494bb0
2 changed files with 6 additions and 6 deletions

View File

@@ -104,7 +104,7 @@ public class CacheSourceService implements CacheSource, Service {
File store = new File(home, "cache/" + name());
if (!store.isFile() || !store.canRead()) return;
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;
while ((line = reader.readLine()) != null) {
if (line.isEmpty()) continue;
@@ -132,7 +132,7 @@ public class CacheSourceService implements CacheSource, Service {
store.getParentFile().mkdirs();
PrintStream stream = new PrintStream(store, "UTF-8");
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) {
stream.println(convert.convertTo(storeType, entry));
}

View File

@@ -29,7 +29,7 @@ public abstract class TypeToken<T> {
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();
String newDynName = TypeToken.class.getName().replace('.', '/') + "_Dyn" + System.currentTimeMillis();
for (;;) {
@@ -44,11 +44,11 @@ public abstract class TypeToken<T> {
FieldVisitor fv;
MethodVisitor mv;
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();
sb.append(rawTypeDesc.substring(0, rawTypeDesc.length() - 1)).append('<');
for (Class c : actualTypeArguments) {
sb.append(jdk.internal.org.objectweb.asm.Type.getDescriptor(c));
for (Type c : actualTypeArguments) {
sb.append(jdk.internal.org.objectweb.asm.Type.getDescriptor((Class) c));
}
sb.append(">;");
{