Is Javascript anonymous function persisted? (Using Java applet, way to hide JS code)

I am writing an application using Javascript. I'm looking for a way to hide my code and I believe I found it using a Java applet.

Anyway, I think this should only be possible if the jon's code of the anonymous functions does not remain available in any way after it has been evaluated.



Applets can get a link to the browser window they are in and call its method eval

to evaluate the js code:

// java code
JSObject window = JSObject.getWindow(this);
window.eval( "(function(){"
  + ...
  + "}).call("
  + thisObjectName
  + ")" );


This way I can change my js code so that some functions instead of the inner code call the applet function, which asks the window for the eval

source code of the js function, navigating to the window anonymous so that the function reference is not saved. Of course, the js function must give the java function the object name ( this

), and the java function must compose an anonymous function adding a method call call(objectName)

to use the reference correctly this


MyJsClass.prototype.func = function() { ... };



MyJsClass.prototype.func = function() 


[UPDATE] My idea was not good for two reasons

  • Java bytecode (.class) is easy to decompile (thanks to Pointy )

  • The function window.eval

    called by the applet is the same thing that you can override via javascript (thanks Yoshi )


source to share

1 answer

Have you considered the next opportunity?

window.eval = function (code) {



Meaning: Almost no effort canceling the function eval




All Articles