Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#60 [Java 5+] Add @Override to finalize() in Java

open
nobody
None
5
2008-01-15
2008-01-15
Hendrik Maryns
No

When using Java 1.5+, the finalize() method should be tagged with @Override when overriding it. It would be nice if there were some option (e.g. --java-version=1.5) that would insert those at the appropriate place.

So when wrapping

extern struct mgTreeNode {
mA a; /* alphabet element */
struct mgTreeNode *left, *right; /* successors */
mgId id; /* state space id */
mgState state; /* automaton state */
};

I’d like the produced class to have


protected static long getCPtr(mgTreeNode obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}

@Override
protected void finalize() {
delete();
}

public synchronized void delete() {
if(swigCPtr != 0 && swigCMemOwn) {
swigCMemOwn = false;
IvbJNI.delete_mgTreeNode(swigCPtr);
}
swigCPtr = 0;
}

Discussion

  • Hendrik Maryns
    Hendrik Maryns
    2008-01-15

    • summary: [Java 5+] Add @Override to finalise() in Java --> [Java 5+] Add @Override to finalize() in Java