changeset in /hg/icedtea6: This commit:
Deepak Bhole
dbhole at redhat.com
Fri Aug 14 12:55:02 PDT 2009
changeset 9457e338943b in /hg/icedtea6
details: http://icedtea.classpath.org/hg/icedtea6?cmd=changeset;node=9457e338943b
description:
This commit:
- Reworks memory allocation to make it less leaky by using heap as little as
possible.
- Implements JSObject.call and JSObject.eval which allow invocation of
JavaScript methods, and execution of arbitrary scripts. Everything except
for array types is currently handled.
- Fixes a few new race conditions that surfaced as result of less
messages/faster initialization.
- Starts laying out call security.
- Fixes unicode handling so that UTF-8 is used correctly across the board.
Most prominently, new sites that now work include:
- Facebook photo uploader
- Yahoo! games applets
- A whole bunch of banking applets
diffstat:
18 files changed, 1390 insertions(+), 705 deletions(-)
ChangeLog | 111 +
plugin/icedteanp/IcedTeaJavaRequestProcessor.cc | 509 +++---
plugin/icedteanp/IcedTeaJavaRequestProcessor.h | 44
plugin/icedteanp/IcedTeaNPPlugin.cc | 47
plugin/icedteanp/IcedTeaNPPlugin.h | 25
plugin/icedteanp/IcedTeaPluginRequestProcessor.cc | 844 +++++++---
plugin/icedteanp/IcedTeaPluginRequestProcessor.h | 23
plugin/icedteanp/IcedTeaPluginUtils.cc | 218 +-
plugin/icedteanp/IcedTeaPluginUtils.h | 49
plugin/icedteanp/IcedTeaRunnable.cc | 3
plugin/icedteanp/IcedTeaRunnable.h | 8
plugin/icedteanp/IcedTeaScriptablePluginObject.cc | 43
plugin/icedteanp/java/netscape/javascript/JSObject.java | 37
plugin/icedteanp/java/sun/applet/GetMemberPluginCallRequest.java | 7
plugin/icedteanp/java/sun/applet/MethodOverloadResolver.java | 19
plugin/icedteanp/java/sun/applet/PluginAppletSecurityContext.java | 40
plugin/icedteanp/java/sun/applet/PluginAppletViewer.java | 49
plugin/icedteanp/java/sun/applet/PluginCookieInfoRequest.java | 19
diffs (truncated from 3394 to 500 lines):
diff -r 9f0b5de9a8eb -r 9457e338943b ChangeLog
--- a/ChangeLog Fri Aug 14 06:12:14 2009 -0400
+++ b/ChangeLog Fri Aug 14 15:58:23 2009 -0400
@@ -1,3 +1,114 @@ 2009-08-14 Gary Benson <gbenson at redhat
+2009-08-14 Deepak Bhole <dbhole at redhat.com>
+
+ * plugin/icedteanp/IcedTeaJavaRequestProcessor.cc
+ (newMessageOnBus): Handle additional request types.
+ (postAndWaitForResponse): Modify parameter type and reset the result
+ before proceeding.
+ (getToStringValue): Remove all heap allocations and allocate on stack.
+ (getString): Same.
+ (deleteReference): Same.
+ (addReference): Same.
+ (findClass): Same.
+ (getClassName): Same.
+ (getClassID): Same.
+ (getFieldID): Same.
+ (getStaticFieldID): Same.
+ (getField): Same. Also, send the source to Java side.
+ (getStaticField): Same.
+ (getMethodID): Remove all heap allocations and allocate on stack.
+ (getStaticMethodID): Same.
+ (callStaticMethod): Same. Also, send the source to Java side.
+ (callMethod): Same.
+ (call): Same.
+ (getObjectClass): Remove all heap allocations and allocate on stack.
+ (newObject): Same. Also, send the source to Java side.
+ (newString): Remove all heap allocations and allocate on stack.
+ (hasPackage): Same.
+ (hasMethod): Same.
+ (hasField): Same.
+ (isInstanceOf): New method.
+ (getAppletObjectInstance): Remove all heap allocations and allocate on
+ stack.
+ * plugin/icedteanp/IcedTeaJavaRequestProcessor.h: Bump timeout to 120 to
+ allow for slower connections. Other misc. changes related to the .cc file
+ changes.
+ * plugin/icedteanp/IcedTeaNPPlugin.cc: Moved GCJPluginData decleration to
+ the header file. Don't initialize message bus and request processors
+ statically.
+ (GCJ_New): Initialize the buses and processors. Store source url in plugin
+ data struct.
+ (GCJ_Destroy): Cleanup source url pointer.
+ * plugin/icedteanp/IcedTeaNPPlugin.h: Moved GCJPluginData struct
+ decleration to here.
+ * plugin/icedteanp/IcedTeaPluginRequestProcessor.cc
+ (getInstanceFromMemberPtr): Moved to plugin utils.
+ (storeInstanceID): Same.
+ (newMessageOnBus): Handle additional request types.
+ (dispatch): Remove unused method.
+ (sendWindow): Remove unnecessary heap allocations and use function stack
+ instead.
+ (eval): New function. Evaluates calls to JavaScript functions and returns
+ the result. Arrays are not yet handled.
+ (call): New function. Evaluates the given script and returns the result.
+ Arrays are not yet handled.
+ (sendString): Remove unnecessary heap allocations and use function stack
+ instead.
+ (setMember): Same.
+ (convertToNPVariant): New function. Narrows given java type to an
+ NPVariant as per type conversion specifications.
+ (sendMember): Remove unnecessary heap allocations and use function stack
+ instead.
+ (storeVariantInJava): New function. Given an NPVariant, does the
+ appropriate conversion and saves it on the Java side. Arrays are not yet
+ handled.
+ (_eval): New function. Evaluates the script via NPN_Evaluate. Meant to be
+ run in the main thread.
+ (_call): New function. Invokes the function via NPN_Invoke. Meant to be run
+ in the main thread.
+ * plugin/icedteanp/IcedTeaPluginRequestProcessor.h: Appropriate changes as
+ necessitated by the above changes in the .cc.
+ * plugin/icedteanp/IcedTeaPluginUtils.cc
+ (constructMessagePrefix): All versions of this functions changed to remove
+ heap allocation, and instead store result in a given pre-allocated parameter.
+ (getReference): Use an ever growing reference number, and cycle when
+ integer max approaches.
+ (releaseReference): Remove code so nothing is done for now.
+ (itoa): Store result in pre-allocated parameter, rather than on heap.
+ (getSourceFromInstance): Given an NPP instance, returns the assocated
+ source.
+ (storeInstanceID): Moved from IcedTeaPluginRequestProcessor. Associates an
+ NPObject with an instance.
+ (getInstanceFromMemberPtr): Moved from IcedTeaPluginRequestProcessor.
+ Given an NPObject, returns the associated instance.
+ (variantToClassName): Remove unused method.
+ * plugin/icedteanp/IcedTeaPluginUtils.h: Appropriate changes as necessitated
+ by the above changes in the .cc.
+ * plugin/icedteanp/IcedTeaRunnable.cc (IcedTeaRunnableMethod): Change
+ result parameter type to void* so that caller/callee can use variable
+ formats.
+ * plugin/icedteanp/IcedTeaRunnable.h: Appropriate changes as necessitated
+ by the above changes in the .cc.
+ * plugin/icedteanp/IcedTeaScriptablePluginObject.cc: Call storeInstanceID
+ and getInstanceFromMemberPtr from plugin utils.
+ (IcedTeaScriptableJavaObject::getProperty): Get the source url and send it to
+ Java side when making the request.
+ (IcedTeaScriptableJavaObject::invoke): Same.
+ * plugin/icedteanp/java/netscape/javascript/JSObject.java: Merge
+ constructor access control fixes from older plugin.
+ * plugin/icedteanp/java/sun/applet/GetMemberPluginCallRequest.java: Handle
+ void and null return types.
+ * plugin/icedteanp/java/sun/applet/MethodOverloadResolver.java: Add an
+ additional test case for Boolean.
+ (getPrimitive): Handle java.lang.Boolean (minor bug fix).
+ * plugin/icedteanp/java/sun/applet/PluginAppletSecurityContext.java: Use
+ URLs when comparing source locations for security verification, rather
+ than String which return false negatives.
+ * plugin/icedteanp/java/sun/applet/PluginAppletViewer.java
+ (handleMessage): Set status to ACTIVE only after initialization finishes.
+ (AppletEventListener::appletStateChanged): Same.
+ * plugin/icedteanp/java/sun/applet/PluginCookieInfoRequest.java
+ (parseReturn): Handle improper cookies from firefox.
+
2009-08-14 Gary Benson <gbenson at redhat.com>
* ports/hotspot/src/share/vm/shark/sharkFunction.hpp
diff -r 9f0b5de9a8eb -r 9457e338943b plugin/icedteanp/IcedTeaJavaRequestProcessor.cc
--- a/plugin/icedteanp/IcedTeaJavaRequestProcessor.cc Fri Aug 14 06:12:14 2009 -0400
+++ b/plugin/icedteanp/IcedTeaJavaRequestProcessor.cc Fri Aug 14 15:58:23 2009 -0400
@@ -111,7 +111,8 @@ JavaRequestProcessor::newMessageOnBus(co
(message_parts->at(4) == "GetFieldID") ||
(message_parts->at(4) == "GetField") ||
(message_parts->at(4) == "GetStaticField") ||
- (message_parts->at(4) == "GetJavaObject"))
+ (message_parts->at(4) == "GetJavaObject") ||
+ (message_parts->at(4) == "IsInstanceOf"))
{
result->return_identifier = atoi(message_parts->at(5).c_str());
result->return_string->append(message_parts->at(5)); // store it as a string as well, for easy access
@@ -159,6 +160,8 @@ JavaRequestProcessor::newMessageOnBus(co
JavaRequestProcessor::JavaRequestProcessor()
{
+ PLUGIN_DEBUG_0ARG("JavaRequestProcessor constructor\n");
+
// caller frees this
result = new JavaResultData();
result->error_msg = new std::string();
@@ -212,15 +215,17 @@ JavaRequestProcessor::resetResult()
}
void
-JavaRequestProcessor::postAndWaitForResponse(std::string* message)
+JavaRequestProcessor::postAndWaitForResponse(std::string message)
{
struct timespec t;
clock_gettime(CLOCK_REALTIME, &t);
t.tv_sec += REQUESTTIMEOUT; // 1 minute timeout
- result_ready = false;
+ // Clear the result
+ resetResult();
+
java_to_plugin_bus->subscribe(this);
- plugin_to_java_bus->post(message->c_str());
+ plugin_to_java_bus->post(message.c_str());
// Wait for result to be filled in.
struct timespec curr_t;
@@ -247,7 +252,7 @@ JavaRequestProcessor::postAndWaitForResp
result->error_msg->append("Error: Timed out when waiting for response");
// Report error
- PLUGIN_DEBUG_1ARG("Error: Timed out when waiting for response to %s\n", message->c_str());
+ PLUGIN_DEBUG_1ARG("Error: Timed out when waiting for response to %s\n", message.c_str());
}
java_to_plugin_bus->unSubscribe(this);
@@ -263,20 +268,19 @@ JavaResultData*
JavaResultData*
JavaRequestProcessor::getToStringValue(std::string object_id)
{
- std::string* message;
+ std::string message = std::string();
this->instance = 0; // context is always 0 (needed for java-side backwards compat.)
this->reference = IcedTeaPluginUtilities::getReference();
- message = IcedTeaPluginUtilities::constructMessagePrefix(0, reference);
-
- message->append(" GetToStringValue "); // get it in UTF8
- message->append(object_id);
+ IcedTeaPluginUtilities::constructMessagePrefix(0, reference, &message);
+
+ message.append(" GetToStringValue "); // get it in UTF8
+ message.append(object_id);
postAndWaitForResponse(message);
IcedTeaPluginUtilities::releaseReference();
- delete message;
return result;
}
@@ -291,20 +295,19 @@ JavaResultData*
JavaResultData*
JavaRequestProcessor::getString(std::string string_id)
{
- std::string* message;
+ std::string message = std::string();
this->instance = 0; // context is always 0 (needed for java-side backwards compat.)
this->reference = IcedTeaPluginUtilities::getReference();
- message = IcedTeaPluginUtilities::constructMessagePrefix(0, reference);
-
- message->append(" GetStringUTFChars "); // get it in UTF8
- message->append(string_id);
+ IcedTeaPluginUtilities::constructMessagePrefix(0, reference, &message);
+
+ message.append(" GetStringUTFChars "); // get it in UTF8
+ message.append(string_id);
postAndWaitForResponse(message);
IcedTeaPluginUtilities::releaseReference();
- delete message;
return result;
}
@@ -318,20 +321,19 @@ void
void
JavaRequestProcessor::deleteReference(std::string object_id)
{
- std::string* message;
-
- this->instance = 0; // context is always 0 (needed for java-side backwards compat.)
- this->reference = IcedTeaPluginUtilities::getReference();
-
- message = IcedTeaPluginUtilities::constructMessagePrefix(0, reference);
-
- message->append(" DeleteLocalRef ");
- message->append(object_id);
-
- postAndWaitForResponse(message);
-
- IcedTeaPluginUtilities::releaseReference();
- delete message;
+ std::string message = std::string();
+
+ this->instance = 0; // context is always 0 (needed for java-side backwards compat.)
+ this->reference = IcedTeaPluginUtilities::getReference();
+
+ IcedTeaPluginUtilities::constructMessagePrefix(0, reference, &message);
+
+ message.append(" DeleteLocalRef ");
+ message.append(object_id);
+
+ postAndWaitForResponse(message);
+
+ IcedTeaPluginUtilities::releaseReference();
}
/**
@@ -343,39 +345,36 @@ void
void
JavaRequestProcessor::addReference(std::string object_id)
{
- std::string* message;
-
- this->instance = 0; // context is always 0 (needed for java-side backwards compat.)
- this->reference = IcedTeaPluginUtilities::getReference();
-
- message = IcedTeaPluginUtilities::constructMessagePrefix(0, reference);
-
- message->append(" NewGlobalRef ");
- message->append(object_id);
-
- postAndWaitForResponse(message);
-
- IcedTeaPluginUtilities::releaseReference();
- delete message;
+ std::string message = std::string();
+
+ this->instance = 0; // context is always 0 (needed for java-side backwards compat.)
+ this->reference = IcedTeaPluginUtilities::getReference();
+
+ IcedTeaPluginUtilities::constructMessagePrefix(0, reference, &message);
+
+ message.append(" NewGlobalRef ");
+ message.append(object_id);
+
+ postAndWaitForResponse(message);
+
+ IcedTeaPluginUtilities::releaseReference();
}
JavaResultData*
JavaRequestProcessor::findClass(std::string name)
{
- std::string* message;
+ std::string message = std::string();
this->instance = 0; // context is always 0 (needed for java-side backwards compat.)
this->reference = IcedTeaPluginUtilities::getReference();
- message = IcedTeaPluginUtilities::constructMessagePrefix(0, reference);
-
- message->append(" FindClass ");
- message->append(name);
-
- postAndWaitForResponse(message);
-
- delete message;
+ IcedTeaPluginUtilities::constructMessagePrefix(0, reference, &message);
+
+ message.append(" FindClass ");
+ message.append(name);
+
+ postAndWaitForResponse(message);
return result;
}
@@ -383,19 +382,17 @@ JavaResultData*
JavaResultData*
JavaRequestProcessor::getClassName(std::string objectID)
{
- std::string* message;
+ std::string message = std::string();
this->instance = 0; // context is always 0 (needed for java-side backwards compat.)
this->reference = IcedTeaPluginUtilities::getReference();
- message = IcedTeaPluginUtilities::constructMessagePrefix(0, reference);
-
- message->append(" GetClassName ");
- message->append(objectID);
-
- postAndWaitForResponse(message);
-
- delete message;
+ IcedTeaPluginUtilities::constructMessagePrefix(0, reference, &message);
+
+ message.append(" GetClassName ");
+ message.append(objectID);
+
+ postAndWaitForResponse(message);
return result;
}
@@ -403,19 +400,17 @@ JavaResultData*
JavaResultData*
JavaRequestProcessor::getClassID(std::string objectID)
{
- std::string* message;
-
- this->instance = 0; // context is always 0 (needed for java-side backwards compat.)
- this->reference = IcedTeaPluginUtilities::getReference();
-
- message = IcedTeaPluginUtilities::constructMessagePrefix(0, reference);
-
- message->append(" GetClassID ");
- message->append(objectID);
-
- postAndWaitForResponse(message);
-
- delete message;
+ std::string message = std::string();
+
+ this->instance = 0; // context is always 0 (needed for java-side backwards compat.)
+ this->reference = IcedTeaPluginUtilities::getReference();
+
+ IcedTeaPluginUtilities::constructMessagePrefix(0, reference, &message);
+
+ message.append(" GetClassID ");
+ message.append(objectID);
+
+ postAndWaitForResponse(message);
return result;
}
@@ -425,25 +420,24 @@ JavaRequestProcessor::getFieldID(std::st
{
JavaResultData* java_result;
JavaRequestProcessor* java_request = new JavaRequestProcessor();
- std::string* message;
+ std::string message = std::string();
java_result = java_request->newString(fieldName);
this->instance = 0; // context is always 0 (needed for java-side backwards compat.)
this->reference = IcedTeaPluginUtilities::getReference();
- message = IcedTeaPluginUtilities::constructMessagePrefix(0, reference);
- message->append(" GetFieldID ");
- message->append(classID);
- message->append(" ");
- message->append(java_result->return_string->c_str());
+ IcedTeaPluginUtilities::constructMessagePrefix(0, reference, &message);
+ message.append(" GetFieldID ");
+ message.append(classID);
+ message.append(" ");
+ message.append(java_result->return_string->c_str());
postAndWaitForResponse(message);
IcedTeaPluginUtilities::releaseReference();
delete java_request;
- delete message;
return result;
}
@@ -453,81 +447,81 @@ JavaRequestProcessor::getStaticFieldID(s
{
JavaResultData* java_result;
JavaRequestProcessor* java_request = new JavaRequestProcessor();
- std::string* message;
+ std::string message = std::string();
java_result = java_request->newString(fieldName);
this->instance = 0; // context is always 0 (needed for java-side backwards compat.)
this->reference = IcedTeaPluginUtilities::getReference();
- message = IcedTeaPluginUtilities::constructMessagePrefix(0, reference);
- message->append(" GetStaticFieldID ");
- message->append(classID);
- message->append(" ");
- message->append(java_result->return_string->c_str());
+ IcedTeaPluginUtilities::constructMessagePrefix(0, reference, &message);
+ message.append(" GetStaticFieldID ");
+ message.append(classID);
+ message.append(" ");
+ message.append(java_result->return_string->c_str());
postAndWaitForResponse(message);
IcedTeaPluginUtilities::releaseReference();
delete java_request;
- delete message;
-
- return result;
-}
-
-JavaResultData*
-JavaRequestProcessor::getField(std::string classID, std::string fieldName)
+
+ return result;
+}
+
+JavaResultData*
+JavaRequestProcessor::getField(std::string source,
+ std::string classID,
+ std::string fieldName)
{
JavaResultData* java_result;
JavaRequestProcessor* java_request = new JavaRequestProcessor();
- std::string* message;
+ std::string message = std::string();
java_result = java_request->getFieldID(classID, fieldName);
this->instance = 0; // context is always 0 (needed for java-side backwards compat.)
this->reference = IcedTeaPluginUtilities::getReference();
- message = IcedTeaPluginUtilities::constructMessagePrefix(0, reference);
- message->append(" GetField ");
- message->append(classID);
- message->append(" ");
- message->append(java_result->return_string->c_str());
+ IcedTeaPluginUtilities::constructMessagePrefix(0, reference, source, &message);
+ message.append(" GetField ");
+ message.append(classID);
+ message.append(" ");
+ message.append(java_result->return_string->c_str());
postAndWaitForResponse(message);
IcedTeaPluginUtilities::releaseReference();
delete java_request;
- delete message;
-
- return result;
-}
-
-JavaResultData*
-JavaRequestProcessor::getStaticField(std::string classID, std::string fieldName)
+
+ return result;
+}
+
+JavaResultData*
+JavaRequestProcessor::getStaticField(std::string classID, std::string source,
+ std::string fieldName)
{
JavaResultData* java_result;
JavaRequestProcessor* java_request = new JavaRequestProcessor();
- std::string* message;
+ std::string message = std::string();
java_result = java_request->getStaticFieldID(classID, fieldName);
this->instance = 0; // context is always 0 (needed for java-side backwards compat.)
this->reference = IcedTeaPluginUtilities::getReference();
More information about the distro-pkg-dev
mailing list