Avoid potential race conditions on the delete() method

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9443 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2006-10-12 21:36:06 +00:00
commit 4ad8d458d2
4 changed files with 31 additions and 7 deletions

View file

@ -1595,17 +1595,24 @@ class JAVA : public Language {
const String *tm = NULL;
Node *attributes = NewHash();
String *destruct_methodname = NULL;
String *destruct_methodmodifiers = NULL;
if (derived) {
tm = typemapLookup("javadestruct_derived", typemap_lookup_type, WARN_NONE, attributes);
destruct_methodname = Getattr(attributes, "tmap:javadestruct_derived:methodname");
destruct_methodmodifiers = Getattr(attributes, "tmap:javadestruct_derived:methodmodifiers");
} else {
tm = typemapLookup("javadestruct", typemap_lookup_type, WARN_NONE, attributes);
destruct_methodname = Getattr(attributes, "tmap:javadestruct:methodname");
destruct_methodmodifiers = Getattr(attributes, "tmap:javadestruct:methodmodifiers");
}
if (!destruct_methodname) {
Swig_error(input_file, line_number,
"No methodname attribute defined in javadestruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name);
}
if (!destruct_methodmodifiers) {
Swig_error(input_file, line_number,
"No methodmodifier attribute defined in javadestruct%s typemap for %s.\n", (derived ? "_derived" : ""), proxy_class_name);
}
// Emit the finalize and delete methods
if (tm) {
@ -1622,7 +1629,7 @@ class JAVA : public Language {
else
Replaceall(destruct, "$jnicall", "throw new UnsupportedOperationException(\"C++ destructor does not have public access\")");
if (*Char(destruct))
Printv(proxy_class_def, "\n ", "public void ", destruct_methodname, "() ", destruct, "\n", NIL);
Printv(proxy_class_def, "\n ", destruct_methodmodifiers, " void ", destruct_methodname, "() ", destruct, "\n", NIL);
}
/* Insert directordisconnect typemap, if this class has directors enabled */