|
@@ -130,16 +130,17 @@ public class JavaNativeModule {
|
130
|
130
|
}
|
131
|
131
|
|
132
|
132
|
public void addGlobals(Class<?> cls) {
|
133
|
|
- HighLevelDefinition definition;
|
134
|
|
- JavaClass jcls;
|
135
|
|
- if(definitionByClass.containsKey(cls)) {
|
136
|
|
- definition = definitionByClass.get(cls);
|
137
|
|
- jcls = compiled.getClassInfo(definition);
|
|
133
|
+
|
|
134
|
+ final HighLevelDefinition definition = addClass(cls);
|
|
135
|
+ final JavaClass jcls;
|
|
136
|
+
|
|
137
|
+ if(compiled.hasClassInfo(definition)) {
|
|
138
|
+ jcls = compiled.getClassInfo(definition);
|
138
|
139
|
} else {
|
139
|
|
- definition = new ClassDefinition(CodePosition.NATIVE, module, pkg, "__globals__", Modifiers.PUBLIC);
|
140
|
140
|
jcls = JavaClass.fromInternalName(getInternalName(cls), JavaClass.Kind.CLASS);
|
141
|
141
|
compiled.setClassInfo(definition, jcls);
|
142
|
142
|
}
|
|
143
|
+
|
143
|
144
|
StoredType thisType = registry.getForMyDefinition(definition).stored();
|
144
|
145
|
//TypeVariableContext context = new TypeVariableContext();
|
145
|
146
|
|
|
@@ -273,14 +274,14 @@ public class JavaNativeModule {
|
273
|
274
|
}
|
274
|
275
|
|
275
|
276
|
private <T> HighLevelDefinition convertClass(Class<T> cls) {
|
276
|
|
- if ((cls.getModifiers() & Modifier.PUBLIC) == 0)
|
277
|
|
- throw new IllegalArgumentException("Class \" " + cls.getName() + "\" must be public");
|
278
|
|
-
|
279
|
|
- if(cls.isAnnotationPresent(ZenCodeType.Expansion.class)) {
|
280
|
|
- return convertExpansion(cls);
|
281
|
|
- }
|
282
|
|
-
|
283
|
|
- String className = cls.getName();
|
|
277
|
+ if((cls.getModifiers() & Modifier.PUBLIC) == 0)
|
|
278
|
+ throw new IllegalArgumentException("Class \" " + cls.getName() + "\" must be public");
|
|
279
|
+
|
|
280
|
+ if(cls.isAnnotationPresent(ZenCodeType.Expansion.class)) {
|
|
281
|
+ return convertExpansion(cls);
|
|
282
|
+ }
|
|
283
|
+
|
|
284
|
+ String className = cls.getName();
|
284
|
285
|
boolean isStruct = cls.isAnnotationPresent(ZenCodeType.Struct.class);
|
285
|
286
|
|
286
|
287
|
HighLevelDefinition definition = checkRegistry(cls);
|
|
@@ -339,25 +340,33 @@ public class JavaNativeModule {
|
339
|
340
|
|
340
|
341
|
//TypeVariableContext context = new TypeVariableContext();
|
341
|
342
|
TypeVariable<Class<T>>[] javaTypeParameters = cls.getTypeParameters();
|
342
|
|
- TypeParameter[] typeParameters = new TypeParameter[cls.getTypeParameters().length];
|
343
|
|
- definition.typeParameters = typeParameters;
|
|
343
|
+ if(!foundRegistry || definition.typeParameters == null || definition.typeParameters.length != cls.getTypeParameters().length) {
|
|
344
|
+ definition.typeParameters = new TypeParameter[cls.getTypeParameters().length];
|
|
345
|
+ }
|
344
|
346
|
|
345
|
347
|
for (int i = 0; i < javaTypeParameters.length; i++) {
|
346
|
348
|
//Put up here for nested parameters?
|
347
|
349
|
TypeVariable<Class<T>> typeVariable = javaTypeParameters[i];
|
348
|
|
- TypeParameter parameter = new TypeParameter(CodePosition.NATIVE, typeVariable.getName());
|
349
|
|
- typeParameters[i] = parameter;
|
|
350
|
+ TypeParameter parameter;
|
|
351
|
+ if(foundRegistry && definition.typeParameters.length == cls.getTypeParameters().length) {
|
|
352
|
+ parameter = definition.typeParameters[i];
|
|
353
|
+ } else {
|
|
354
|
+ parameter = new TypeParameter(CodePosition.NATIVE, typeVariable.getName());
|
|
355
|
+ }
|
|
356
|
+ definition.typeParameters[i] = parameter;
|
350
|
357
|
context.put(typeVariable, parameter);
|
351
|
358
|
}
|
352
|
359
|
|
353
|
360
|
for (int i = 0; i < javaTypeParameters.length; i++) {
|
354
|
361
|
TypeVariable<Class<T>> typeVariable = javaTypeParameters[i];
|
355
|
|
- TypeParameter parameter = typeParameters[i];
|
|
362
|
+ TypeParameter parameter = definition.typeParameters[i];
|
356
|
363
|
for (AnnotatedType bound : typeVariable.getAnnotatedBounds()) {
|
|
364
|
+ if(bound.getType() == Object.class) {
|
|
365
|
+ continue; //Makes the stdlibs types work as they have "no" bounds for T
|
|
366
|
+ }
|
357
|
367
|
TypeID type = loadType(context, bound).type;
|
358
|
368
|
parameter.addBound(new ParameterTypeBound(CodePosition.NATIVE, type));
|
359
|
369
|
}
|
360
|
|
- typeParameters[i] = parameter;
|
361
|
370
|
}
|
362
|
371
|
|
363
|
372
|
if (!foundRegistry && definition instanceof ClassDefinition && cls.getAnnotatedSuperclass() != null && shouldLoadType(cls.getAnnotatedSuperclass().getType())) {
|