Bug 327846 - Method names conflicting with Java keywords should have underscore prepended, not appended. Expand list of Java keywords. General cleanup. r=bsmedberg. xulrunner only
git-svn-id: svn://10.0.0.236/trunk@193284 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -95,6 +95,34 @@ JavaToXPTCStubMap* gJavaToXPTCStubMap = nsnull;
|
||||
PRBool gJavaXPCOMInitialized = PR_FALSE;
|
||||
PRLock* gJavaXPCOMLock = nsnull;
|
||||
|
||||
static const char* kJavaKeywords[] = {
|
||||
"abstract", "default" , "if" , "private" , "throw" ,
|
||||
"boolean" , "do" , "implements", "protected" , "throws" ,
|
||||
"break" , "double" , "import", "public" , "transient" ,
|
||||
"byte" , "else" , "instanceof", "return" , "try" ,
|
||||
"case" , "extends" , "int" , "short" , "void" ,
|
||||
"catch" , "final" , "interface" , "static" , "volatile" ,
|
||||
"char" , "finally" , "long" , "super" , "while" ,
|
||||
"class" , "float" , "native" , "switch" ,
|
||||
"const" , "for" , "new" , "synchronized",
|
||||
"continue", "goto" , "package" , "this" ,
|
||||
/* added in Java 1.2 */
|
||||
"strictfp",
|
||||
/* added in Java 1.4 */
|
||||
"assert" ,
|
||||
/* added in Java 5.0 */
|
||||
"enum" ,
|
||||
/* Java constants */
|
||||
"true" , "false" , "null" ,
|
||||
/* java.lang.Object methods *
|
||||
* - don't worry about "toString", since it does the same thing *
|
||||
* as Object's "toString" */
|
||||
"clone" , "equals" , "finalize" , "getClass" , "hashCode" ,
|
||||
"notify" , "notifyAll", /*"toString" ,*/ "wait"
|
||||
};
|
||||
|
||||
nsTHashtable<nsDepCharHashKey>* gJavaKeywords = nsnull;
|
||||
|
||||
|
||||
/******************************
|
||||
* InitializeJavaGlobals
|
||||
@@ -245,16 +273,35 @@ InitializeJavaGlobals(JNIEnv *env)
|
||||
#endif
|
||||
|
||||
gNativeToJavaProxyMap = new NativeToJavaProxyMap();
|
||||
if (NS_FAILED(gNativeToJavaProxyMap->Init())) {
|
||||
if (!gNativeToJavaProxyMap || NS_FAILED(gNativeToJavaProxyMap->Init())) {
|
||||
NS_WARNING("Problem creating NativeToJavaProxyMap");
|
||||
goto init_error;
|
||||
}
|
||||
gJavaToXPTCStubMap = new JavaToXPTCStubMap();
|
||||
if (NS_FAILED(gJavaToXPTCStubMap->Init())) {
|
||||
if (!gJavaToXPTCStubMap || NS_FAILED(gJavaToXPTCStubMap->Init())) {
|
||||
NS_WARNING("Problem creating JavaToXPTCStubMap");
|
||||
goto init_error;
|
||||
}
|
||||
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
PRUint32 size = NS_ARRAY_LENGTH(kJavaKeywords);
|
||||
gJavaKeywords = new nsTHashtable<nsDepCharHashKey>();
|
||||
if (!gJavaKeywords || NS_FAILED(gJavaKeywords->Init(size))) {
|
||||
NS_WARNING("Failed to init JavaKeywords HashSet");
|
||||
goto init_error;
|
||||
}
|
||||
for (PRUint32 i = 0; i < size && NS_SUCCEEDED(rv); i++) {
|
||||
if (!gJavaKeywords->PutEntry(kJavaKeywords[i])) {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to populate JavaKeywords hash");
|
||||
goto init_error;
|
||||
}
|
||||
}
|
||||
|
||||
gJavaXPCOMLock = PR_NewLock();
|
||||
gJavaXPCOMInitialized = PR_TRUE;
|
||||
return PR_TRUE;
|
||||
@@ -346,6 +393,11 @@ FreeJavaGlobals(JNIEnv* env)
|
||||
xpcomJavaProxyClass = nsnull;
|
||||
}
|
||||
|
||||
if (gJavaKeywords) {
|
||||
delete gJavaKeywords;
|
||||
gJavaKeywords = nsnull;
|
||||
}
|
||||
|
||||
if (tempLock) {
|
||||
PR_Unlock(tempLock);
|
||||
PR_DestroyLock(tempLock);
|
||||
|
||||
Reference in New Issue
Block a user