/hg/icedtea: 2 new changesets
dbhole at icedtea.classpath.org
dbhole at icedtea.classpath.org
Thu Dec 24 11:01:44 PST 2009
changeset f10cc2673959 in /hg/icedtea
details: http://icedtea.classpath.org/hg/icedtea?cmd=changeset;node=f10cc2673959
author: Deepak Bhole <dbhole at redhat.com>
date: Thu Dec 24 14:01:07 2009 -0500
Set JDK_UPDATE_VERSION based on upstream drop version
changeset 316dbf49f070 in /hg/icedtea
details: http://icedtea.classpath.org/hg/icedtea?cmd=changeset;node=316dbf49f070
author: Deepak Bhole <dbhole at redhat.com>
date: Thu Dec 24 14:05:23 2009 -0500
- Blanket merge for np plugin code from icedtea6 branch.
diffstat:
19 files changed, 1408 insertions(+), 885 deletions(-)
ChangeLog | 10
Makefile.am | 2
netx/net/sourceforge/jnlp/Launcher.java | 6
plugin/icedteanp/IcedTeaJavaRequestProcessor.cc | 365 ++++-
plugin/icedteanp/IcedTeaJavaRequestProcessor.h | 53
plugin/icedteanp/IcedTeaNPPlugin.cc | 126 -
plugin/icedteanp/IcedTeaNPPlugin.h | 11
plugin/icedteanp/IcedTeaPluginRequestProcessor.cc | 687 +++-------
plugin/icedteanp/IcedTeaPluginRequestProcessor.h | 9
plugin/icedteanp/IcedTeaPluginUtils.cc | 306 ++++
plugin/icedteanp/IcedTeaPluginUtils.h | 70 -
plugin/icedteanp/IcedTeaRunnable.h | 2
plugin/icedteanp/IcedTeaScriptablePluginObject.cc | 260 +--
plugin/icedteanp/IcedTeaScriptablePluginObject.h | 14
plugin/icedteanp/java/netscape/javascript/JSObject.java | 7
plugin/icedteanp/java/sun/applet/MethodOverloadResolver.java | 139 +-
plugin/icedteanp/java/sun/applet/PluginAppletSecurityContext.java | 103 +
plugin/icedteanp/java/sun/applet/PluginAppletViewer.java | 120 +
plugin/icedteanp/java/sun/applet/PluginCallRequestFactory.java | 3
diffs (truncated from 3807 to 500 lines):
diff -r a58d87327776 -r 316dbf49f070 ChangeLog
--- a/ChangeLog Thu Dec 24 02:12:53 2009 +0000
+++ b/ChangeLog Thu Dec 24 14:05:23 2009 -0500
@@ -1,3 +1,13 @@ 2009-12-23 Andrew John Hughes <ahughes
+2009-12-24 Deepak Bhole <dbhole at redhat.com>
+
+ * plugin/icedeanp/*: Blanket merge with icedtea6 branch.
+ * netx/net/sourceforge/jnlp/Launcher.java: Switch to only import necessary
+ classes rather than *.
+
+2009-12-22 Deepak Bhole <dbhole at redhat.com>
+
+ * Makefile.am: Set JDK_UPDATE_VERSION based on upstream drop version
+
2009-12-23 Andrew John Hughes <ahughes at redhat.com>
* Makefile.am:
diff -r a58d87327776 -r 316dbf49f070 Makefile.am
--- a/Makefile.am Thu Dec 24 02:12:53 2009 +0000
+++ b/Makefile.am Thu Dec 24 14:05:23 2009 -0500
@@ -432,7 +432,7 @@ else
ICEDTEA_SHARK_BUILD =
endif
-JDK_UPDATE_VERSION = 0
+JDK_UPDATE_VERSION = $(shell echo $(OPENJDK_VERSION) | sed -e "s/^b//")
COMBINED_VERSION = $(JDK_UPDATE_VERSION)-$(OPENJDK_VERSION)
ICEDTEA_ENV = \
diff -r a58d87327776 -r 316dbf49f070 netx/net/sourceforge/jnlp/Launcher.java
--- a/netx/net/sourceforge/jnlp/Launcher.java Thu Dec 24 02:12:53 2009 +0000
+++ b/netx/net/sourceforge/jnlp/Launcher.java Thu Dec 24 14:05:23 2009 -0500
@@ -19,11 +19,13 @@ package net.sourceforge.jnlp;
import java.applet.Applet;
import java.awt.Container;
-import java.io.*;
+import java.io.File;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadMXBean;
import java.lang.reflect.Method;
-import java.net.*;
+import java.net.InetAddress;
+import java.net.URL;
+import java.net.UnknownHostException;
import java.util.LinkedList;
import java.util.List;
import java.util.jar.JarFile;
diff -r a58d87327776 -r 316dbf49f070 plugin/icedteanp/IcedTeaJavaRequestProcessor.cc
--- a/plugin/icedteanp/IcedTeaJavaRequestProcessor.cc Thu Dec 24 02:12:53 2009 +0000
+++ b/plugin/icedteanp/IcedTeaJavaRequestProcessor.cc Thu Dec 24 14:05:23 2009 -0500
@@ -36,6 +36,8 @@ obligated to do so. If you do not wish
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+#include <typeinfo>
+
#include "IcedTeaJavaRequestProcessor.h"
#include "IcedTeaScriptablePluginObject.h"
@@ -68,7 +70,7 @@ JavaRequestProcessor::newMessageOnBus(co
// Gather the results
// Let's get errors out of the way first
- if (message_parts->at(4) == "Error")
+ if (message_parts->at(4).find("Error") == 0)
{
for (int i=5; i < message_parts->size(); i++)
{
@@ -111,7 +113,8 @@ JavaRequestProcessor::newMessageOnBus(co
(message_parts->at(4) == "GetStaticFieldID") ||
(message_parts->at(4) == "GetFieldID") ||
(message_parts->at(4) == "GetJavaObject") ||
- (message_parts->at(4) == "IsInstanceOf"))
+ (message_parts->at(4) == "IsInstanceOf") ||
+ (message_parts->at(4) == "NewArray"))
{
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
@@ -124,6 +127,7 @@ JavaRequestProcessor::newMessageOnBus(co
(message_parts->at(4) == "CallStaticMethod") ||
(message_parts->at(4) == "GetField") ||
(message_parts->at(4) == "GetStaticField") ||
+ (message_parts->at(4) == "GetValue") ||
(message_parts->at(4) == "GetObjectArrayElement"))
{
@@ -131,6 +135,8 @@ JavaRequestProcessor::newMessageOnBus(co
{
// literal returns don't have a corresponding jni id
result->return_identifier = 0;
+ result->return_string->append(message_parts->at(5));
+ result->return_string->append(" ");
result->return_string->append(message_parts->at(6));
} else
@@ -300,6 +306,33 @@ JavaRequestProcessor::getToStringValue(s
}
/**
+ * Given an object id, fetches the value of that ID from Java
+ *
+ * @param object_id The ID of the object
+ * @return A JavaResultData struct containing the result of the request
+ */
+
+JavaResultData*
+JavaRequestProcessor::getValue(std::string object_id)
+{
+ 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(" GetValue "); // get it in UTF8
+ message.append(object_id);
+
+ postAndWaitForResponse(message);
+
+ IcedTeaPluginUtilities::releaseReference();
+
+ return result;
+}
+
+/**
* Given a string id, fetches the actual string from Java side
*
* @param string_id The ID of the string
@@ -475,12 +508,9 @@ JavaResultData*
JavaResultData*
JavaRequestProcessor::setSlot(std::string objectID,
std::string index,
- NPVariant value)
-{
- std::string id = std::string();
- std::string message = std::string();
-
- createJavaObjectFromVariant(value, &id);
+ std::string value_id)
+{
+ std::string message = std::string();
this->instance = 0; // context is always 0 (needed for java-side backwards compat.)
this->reference = IcedTeaPluginUtilities::getReference();
@@ -492,7 +522,30 @@ JavaRequestProcessor::setSlot(std::strin
message.append(" ");
message.append(index);
message.append(" ");
- message.append(id);
+ message.append(value_id);
+
+ postAndWaitForResponse(message);
+
+ IcedTeaPluginUtilities::releaseReference();
+
+ return result;
+}
+
+JavaResultData*
+JavaRequestProcessor::newArray(std::string array_class,
+ std::string length)
+{
+ 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(" NewArray ");
+ message.append(array_class);
+ message.append(" ");
+ message.append(length);
postAndWaitForResponse(message);
@@ -620,14 +673,11 @@ JavaRequestProcessor::set(std::string so
std::string classID,
std::string objectID,
std::string fieldName,
- NPVariant value)
+ std::string value_id)
{
JavaResultData* java_result;
JavaRequestProcessor java_request = JavaRequestProcessor();
- std::string id = std::string();
- std::string message = std::string();
-
- createJavaObjectFromVariant(value, &id);
+ std::string message = std::string();
java_result = java_request.getFieldID(classID, fieldName);
@@ -649,7 +699,7 @@ JavaRequestProcessor::set(std::string so
message.append(" ");
message.append(java_result->return_string->c_str());
message.append(" ");
- message.append(id);
+ message.append(value_id);
postAndWaitForResponse(message);
@@ -662,9 +712,9 @@ JavaRequestProcessor::setStaticField(std
JavaRequestProcessor::setStaticField(std::string source,
std::string classID,
std::string fieldName,
- NPVariant value)
-{
- return set(source, true, classID, "", fieldName, value);
+ std::string value_id)
+{
+ return set(source, true, classID, "", fieldName, value_id);
}
JavaResultData*
@@ -672,9 +722,9 @@ JavaRequestProcessor::setField(std::stri
std::string classID,
std::string objectID,
std::string fieldName,
- NPVariant value)
-{
- return set(source, false, classID, objectID, fieldName, value);
+ std::string value_id)
+{
+ return set(source, false, classID, objectID, fieldName, value_id);
}
JavaResultData*
@@ -754,7 +804,35 @@ JavaRequestProcessor::getStaticMethodID(
}
void
-JavaRequestProcessor::createJavaObjectFromVariant(NPVariant variant, std::string* id)
+getArrayTypeForJava(NPP instance, NPVariant element, std::string* type)
+{
+
+ if (NPVARIANT_IS_BOOLEAN(element)) {
+ type->append("string");
+ } else if (NPVARIANT_IS_INT32(element)) {
+ type->append("string");
+ } else if (NPVARIANT_IS_DOUBLE(element)) {
+ type->append("string");
+ } else if (NPVARIANT_IS_STRING(element)) {
+ type->append("string");
+ } else if (NPVARIANT_IS_OBJECT(element)) {
+
+ NPObject* first_element_obj = NPVARIANT_TO_OBJECT(element);
+ if (IcedTeaScriptableJavaPackageObject::is_valid_java_object(first_element_obj))
+ {
+ std::string class_id = std::string(((IcedTeaScriptableJavaObject*) first_element_obj)->getClassID());
+ type->append(class_id);
+ } else
+ {
+ type->append("jsobject");
+ }
+ } else {
+ type->append("jsobject"); // Else it is a string
+ }
+}
+
+void
+createJavaObjectFromVariant(NPP instance, NPVariant variant, std::string* id)
{
JavaResultData* java_result;
@@ -773,14 +851,12 @@ JavaRequestProcessor::createJavaObjectFr
PLUGIN_DEBUG_1ARG("VOID %d\n", variant);
id->append("0");
return; // no need to go further
- }
- else if (NPVARIANT_IS_NULL(variant))
+ } else if (NPVARIANT_IS_NULL(variant))
{
PLUGIN_DEBUG_1ARG("NULL\n", variant);
id->append("0");
return; // no need to go further
- }
- else if (NPVARIANT_IS_BOOLEAN(variant))
+ } else if (NPVARIANT_IS_BOOLEAN(variant))
{
className = "java.lang.Boolean";
@@ -789,8 +865,7 @@ JavaRequestProcessor::createJavaObjectFr
else
stringArg = "false";
- }
- else if (NPVARIANT_IS_INT32(variant))
+ } else if (NPVARIANT_IS_INT32(variant))
{
className = "java.lang.Integer";
@@ -798,8 +873,7 @@ JavaRequestProcessor::createJavaObjectFr
sprintf(valueStr, "%d", NPVARIANT_TO_INT32(variant));
stringArg += valueStr;
free(valueStr);
- }
- else if (NPVARIANT_IS_DOUBLE(variant))
+ } else if (NPVARIANT_IS_DOUBLE(variant))
{
className = "java.lang.Double";
@@ -807,8 +881,7 @@ JavaRequestProcessor::createJavaObjectFr
sprintf(valueStr, "%f", NPVARIANT_TO_DOUBLE(variant));
stringArg += valueStr;
free(valueStr);
- }
- else if (NPVARIANT_IS_STRING(variant))
+ } else if (NPVARIANT_IS_STRING(variant))
{
className = "java.lang.String";
#if MOZILLA_VERSION_COLLAPSED < 1090200
@@ -816,28 +889,174 @@ JavaRequestProcessor::createJavaObjectFr
#else
stringArg += NPVARIANT_TO_STRING(variant).UTF8Characters;
#endif
+ } else if (NPVARIANT_IS_OBJECT(variant))
+ {
+
+ NPObject* obj = NPVARIANT_TO_OBJECT(variant);
+ if (IcedTeaScriptableJavaPackageObject::is_valid_java_object(obj))
+ {
+ PLUGIN_DEBUG_0ARG("NPObject is a Java object\n");
+ alreadyCreated = true;
+ } else
+ {
+ PLUGIN_DEBUG_0ARG("NPObject is not a Java object");
+ NPIdentifier length_id = browser_functions.getstringidentifier("length");
+
+ // FIXME: We currently only handle <= 2 dim arrays. Do we really need more though?
+
+ // Is it an array?
+ if (IcedTeaPluginUtilities::isObjectJSArray(instance, obj)) {
+ PLUGIN_DEBUG_0ARG("NPObject is an array\n");
+
+ std::string array_id = std::string();
+ std::string java_array_type = std::string();
+ NPVariant length = NPVariant();
+ browser_functions.getproperty(instance, obj, length_id, &length);
+
+ std::string length_str = std::string();
+ IcedTeaPluginUtilities::itoa(NPVARIANT_TO_INT32(length), &length_str);
+
+ if (NPVARIANT_TO_INT32(length) > 0)
+ {
+ NPIdentifier id_0 = browser_functions.getintidentifier(0);
+ NPVariant first_element = NPVariant();
+ browser_functions.getproperty(instance, obj, id_0, &first_element);
+
+ // Check for multi-dim array
+ if (NPVARIANT_IS_OBJECT(first_element) &&
+ IcedTeaPluginUtilities::isObjectJSArray(instance, NPVARIANT_TO_OBJECT(first_element))) {
+
+ NPVariant first_nested_element = NPVariant();
+ browser_functions.getproperty(instance, NPVARIANT_TO_OBJECT(first_element), id_0, &first_nested_element);
+
+ getArrayTypeForJava(instance, first_nested_element, &java_array_type);
+
+ length_str.append(" 0"); // secondary array is created on the fly
+ } else
+ {
+ getArrayTypeForJava(instance, first_element, &java_array_type);
+ }
+ } else
+ java_array_type.append("jsobject");
+
+ java_result = java_request.newArray(java_array_type, length_str);
+
+ if (java_result->error_occurred) {
+ printf("Unable to create array\n");
+ id->append("-1");
+ return;
+ }
+
+ id->append(*(java_result->return_string));
+
+ NPIdentifier index_id = NPIdentifier();
+ for (int i=0; i < NPVARIANT_TO_INT32(length); i++)
+ {
+ NPVariant value = NPVariant();
+
+ index_id = browser_functions.getintidentifier(i);
+ browser_functions.getproperty(instance, obj, index_id, &value);
+
+ std::string value_id = std::string();
+ createJavaObjectFromVariant(instance, value, &value_id);
+
+ if (value_id == "-1") {
+ printf("Unable to populate array\n");
+ id->clear();
+ id->append("-1");
+ return;
+ }
+
+ std::string value_str = std::string();
+ IcedTeaPluginUtilities::itoa(i, &value_str);
+ java_result = java_request.setSlot(*id, value_str, value_id);
+
+ }
+
+ // Got here => no errors above. We're good to return!
+ return;
+ } else // Else it is not an array
+ {
+
+ NPVariant* variant_copy = new NPVariant();
+ OBJECT_TO_NPVARIANT(NPVARIANT_TO_OBJECT(variant), *variant_copy);
+
+ className = "netscape.javascript.JSObject";
+ IcedTeaPluginUtilities::JSIDToString(variant_copy, &stringArg);
+ browser_functions.retainobject(NPVARIANT_TO_OBJECT(variant));
+
+ std::string jsObjectClassID = std::string();
+ std::string jsObjectConstructorID = std::string();
+ std::vector<std::string> args = std::vector<std::string>();
+
+ java_result = java_request.findClass(0, "netscape.javascript.JSObject");
+
+ // the result we want is in result_string (assuming there was no error)
+ if (java_result->error_occurred)
+ {
+ printf("Unable to get JSObject class id\n");
+ id->clear();
+ id->append("-1");
+ return;
+ }
+
+ jsObjectClassID.append(*(java_result->return_string));
+ args.push_back("J");
+
+ java_result = java_request.getMethodID(jsObjectClassID,
+ browser_functions.getstringidentifier("<init>"),
+ args);
+
+ // the result we want is in result_string (assuming there was no error)
+ if (java_result->error_occurred)
+ {
+ printf("Unable to get JSObject constructor id\n");
+ id->clear();
+ id->append("-1");
+ return;
+ }
+
+ jsObjectConstructorID.append(*(java_result->return_string));
+
+ // We have the method id. Now create a new object.
+
+ args.clear();
+ args.push_back(stringArg);
+ java_result = java_request.newObjectWithConstructor("",
+ jsObjectClassID,
+ jsObjectConstructorID,
+ args);
+
+ // Store the instance ID for future reference
+ IcedTeaPluginUtilities::storeInstanceID(variant_copy, instance);
+
+ // the result we want is in result_string (assuming there was no error)
+ // the result we want is in result_string (assuming there was no error)
+ if (java_result->error_occurred)
+ {
+ printf("Unable to create JSObject\n");
+ id->clear();
+ id->append("-1");
+ return;
+ }
+
+ id->append(*(java_result->return_string));
+ return;
+ }
+ }
}
- else if (browser_functions.getproperty())
- {
-
- }
- else
- {
- alreadyCreated = true;
- }
if (!alreadyCreated) {
- java_result = java_request.findClass(0, className.c_str());
+ java_result = java_request.findClass(0, className);
// the result we want is in result_string (assuming there was no error)
if (java_result->error_occurred) {
printf("Unable to find classid for %s\n", className.c_str());
- id->append("0");
+ id->append("-1");
return;
}
jsObjectClassID.append(*(java_result->return_string));
- java_request.resetResult();
std::string stringClassName = "Ljava/lang/String;";
args.push_back(stringClassName);
More information about the distro-pkg-dev
mailing list