Truffle and support for a class name 'Object'
Bernhard Urban
bernhard.urban at jku.at
Mon Sep 16 05:04:32 PDT 2013
There's also a nice example in the book "Java Puzzlers" [1] why it's
generally not a good idea to use names from classes living in java.lang.
[1] http://www.javapuzzlers.com/java-puzzlers-sampler.pdf (Page 16)
On 09/13/2013 12:02 AM, Thomas Wuerthinger wrote:
> Thanks for the report. We will add support for checking name clashes. In general, we would like to suggest the use of class name prefixes for language implementations to avoid clashes with the Java standard library or other guest language implementations. - thomas
>
> On Sep 12, 2013, at 11:43 PM, Stefan Marr <java at stefan-marr.de> wrote:
>
>> 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