contrib/jwrapper: only reference to `java.lang.Object` if known by the model
authorAlexis Laferrière <alexis.laf@xymus.net>
Tue, 4 Aug 2015 18:24:33 +0000 (14:24 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Wed, 5 Aug 2015 01:41:51 +0000 (21:41 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

contrib/jwrapper/src/code_generator.nit
contrib/jwrapper/src/model.nit

index e81a2bb..02a3cb5 100644 (file)
@@ -196,7 +196,8 @@ class CodeGenerator
                end
 
                if effective_supers == 0 then
-                       if java_class.class_type.package_name == "java.lang.Object" then
+                       if java_class.class_type.package_name == "java.lang.Object" or
+                          not model.knows_the_object_class then
                                supers.add "super JavaObject"
                        else supers.add "super Java_lang_Object"
                end
index 456f496..74f90b5 100644 (file)
@@ -287,6 +287,9 @@ class JavaModel
                return classes
        end
 
+       # Does this model have access to the `java.lang.Object`?
+       var knows_the_object_class: Bool = all_classes.keys.has("java.lang.Object") is lazy
+
        # Add a class in `classes`
        fun add_class(jclass: JavaClass)
        do
@@ -390,8 +393,9 @@ class JavaModel
                                if not all_classes.keys.has(super_type.package_name) then super_classes.remove(super_type)
                        end
 
-                       # If the is no explicit supers, add `java.lang.Object`
-                       if super_classes.is_empty and java_class.class_type != object_type then
+                       # If the is no explicit supers, add `java.lang.Object` (if it is known)
+                       if super_classes.is_empty and java_class.class_type != object_type and
+                          knows_the_object_class then
                                super_classes.add object_type
                        end