Menu

#16 Translation of the Object.finalize() into C# destructor

open
None
5
2010-01-11
2009-11-26
No

I want to transform the finalize() method of every Object into the C# destructor notation : ~class_name(). (Note: C# does not allow to extend the method Finalize()).

For example :
class TestClass {
protected finalize() {
// ...
}
}

will translate to :
class TestClass {
~TestClass() {
// ...
}
}

So in the mapping i suggest to have a parameter telling the name of the resulting C# class (%C#_Class), and the mapping should be quite straight forward :

class java.lang.Object :: System:Object {
method finalize() { name = ~%C#_Class;}
}

So every finalize() method will translate into :
~class_name() {
...
}

Discussion

  • Thomas Colin de Verdičre

    In fact it is a bug because you can't rename the finalize method with ~ClassName because the ~ is not supported.
    I think the translator should replace automatically finalize() by the destructor ~ClassName()

     
  • Alexandre FAU

    Alexandre FAU - 2010-01-11
    • assigned_to: nobody --> alexandrefau
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.