Truffle and support for a class name 'Object'

Stefan Marr java at stefan-marr.de
Thu Sep 12 14:43:12 PDT 2013


Dear all:

I would like to request a feature:

 Could you please support the class name 'Object' for guest language implementations?
 Or, could you put a big red warning into the Truffle FAQ to avoid it?

If you would consider solution 1, this patch might be useful for some people:

diff --git a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/codewriter/OrganizedImports.java b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/codewriter/OrganizedImports.java
index b94912e..e97517d 100644
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/codewriter/OrganizedImports.java
+++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/codewriter/OrganizedImports.java
@@ -137,6 +137,10 @@ public final class OrganizedImports {
     private String createDeclaredTypeName(Element enclosedElement, DeclaredType type) {
         String name = type.asElement().getSimpleName().toString();

+        if ("Object".equals(name)) {
+            return getQualifiedName(type);
+        }
+
         if (needsImport(enclosedElement, type)) {
             TypeMirror usedByType = simpleNamesUsed.get(name);
             if (usedByType == null) {


I had a similar patch for Utils.getDeclaredName() which might not be necessary anymore.
However, this one in OrganizedImports is necessary to generate proper specialized classes when using the Truffle-DSL for type specializations.

As mentioned with the original patch, this is also only a work-around. A proper solution might require to check for name clashes directly.

Thanks
Stefan



-- 
Stefan Marr
Software Languages Lab
Vrije Universiteit Brussel
Pleinlaan 2 / B-1050 Brussels / Belgium
http://soft.vub.ac.be/~smarr
Phone: +32 2 629 2974
Fax:   +32 2 629 3525



More information about the graal-dev mailing list