Permalink
Browse files

Example of changing the HTML DOM structure with Java Bytecode

  • Loading branch information...
2 parents 8fdec07 + cd53e40 commit 34ce88ee6250659e0d678a50cd632d4576699d51 @nurv committed Nov 17, 2011
Binary file not shown.
@@ -0,0 +1,5 @@
+package bicavm.browser;
+
+public class Window{
+ public static native void setTitle(String title);
+}
View
Binary file not shown.
View
@@ -4,7 +4,7 @@
public class foo{
public static void main(String[] args){
String hello = "bicavm";
- String world = "changed this title";
+ String world = " changed this title";
Window.setTitle(hello + world);
}
}
View
@@ -940,18 +940,18 @@ DEFOP(INVOKESTATIC)
LOG("Calling " + className + " " + method.name_ref.str + method.descriptor_ref.str)
LOG("!! NATIVE !!")
if (xl.jvm.internalJNITable[className] && methodId in xl.jvm.internalJNITable[className]){
- result = xl.jvm.internalJNITable[className][methodId].apply(cl,args);
+ result = {return_object: xl.jvm.internalJNITable[className][methodId].apply(cl,args)};
}else if (xl.jvm.JNITable[className] && methodId in xl.jvm.JNITable[className]){
- result = xl.jvm.JNITable[className][methodId].apply(cl,args)
+ result = {return_object: xl.jvm.JNITable[className][methodId].apply(cl,args)};s
}else{
PANIC(methodId + " declared as native but not mapped");
}
LOG("Returing from " + className + " " + method.name_ref.str + method.descriptor_ref.str)
}else{
result = method.invoke(args,cl);
}
- if (result != undefined){
- OPPUSH(result);
+ if (result != undefined && result.return_object!= undefined){
+ OPPUSH(result.return_object);
}
ENDDEF
@@ -51,7 +51,6 @@ function java_lang_Double_doubleToRawLongBits(d){
return new math.Long(y[0],y[1]);
}
-function bicavm_browser_Window_setLocation(s){
+function bicavm_browser_Window_setTitle(s){
window.document.title = javaString2JS(s);
}
-

0 comments on commit 34ce88e

Please sign in to comment.