Bck2Brwsr

From APIDesign

(Difference between revisions)
Jump to: navigation, search
(Resources)
Current revision (04:38, 1 October 2021) (edit) (undo)
 
(47 intermediate revisions not shown.)
Line 1: Line 1:
 +
[[Bck2Brwsr]] [[VM]] is a [[Java]] [[VM|virtual machine]] which is capable to take [[bytecode]] and convert it (either ahead-of-time e - e.g. during compilation - or just-in-time, e.g. in a browser) into appropriate [[JavaScript]] code which does the same thing. As a result one can write in [[Java]], compile with [[JavaC]], process it with [[Bck2Brwsr]] (usually via its [[Maven]] plugin, but possibly also directly via [[Bck2BrwsrJavadoc|programmatic APIs]]) into a [[JavaScript]] file(s) that can be executed in any modern browser (IE 10 at least, please).
 +
 +
The easiest way to start is to play with a [[DEW]] - the Development Environment for Web. Just visit http://dew.apidesign.org/dew and edit, compile, run in a browser without installing anything or using (now banned) [[Java]] plugins.
 +
 +
The [[Bck2Brwsr]] project supports the generic and portable [[Html4Java|HTML/Java APIs]] as defined by [[NetBeans]]. Use them to run your application on [[FXBrwsr|desktop]] as a standalone application, as a [[HTML|NetBeans or Eclipse]] plugin or in a browser, via [[Bck2Brwsr]] [[VM]].
 +
 +
== Motivation ==
 +
During my duties at [[JavaOne2012]] my feeling (primed by observing various [[RSS]] feeds full of posts about something which ends '''.js''') that [[Java]] is no longer as [[good|cool]] as it used to be straightened. It always starts by loosing interest of newcomers, targeting just a piece of the technology segment and soon once [[Good Technology]] becomes new [[COBOL]]. Can that happen to [[Java]]? Just read [http://mashable.com/2012/11/12/javascript/ Is JavaScript the Future of Programming?] and (if you like [[Java]]), you'll get scared. I decided to do something about that. I'd like to return my favorite programming language [[Bck2Brwsr]].
During my duties at [[JavaOne2012]] my feeling (primed by observing various [[RSS]] feeds full of posts about something which ends '''.js''') that [[Java]] is no longer as [[good|cool]] as it used to be straightened. It always starts by loosing interest of newcomers, targeting just a piece of the technology segment and soon once [[Good Technology]] becomes new [[COBOL]]. Can that happen to [[Java]]? Just read [http://mashable.com/2012/11/12/javascript/ Is JavaScript the Future of Programming?] and (if you like [[Java]]), you'll get scared. I decided to do something about that. I'd like to return my favorite programming language [[Bck2Brwsr]].
 +
 +
== Licensing ==
 +
 +
The code of [[Bck2Brwsr]] is heavily derived from [[OpenJDK]] source code (especially the libraries part, not the [[HotSpot]] part). [[Bck2Brwsr]] thus needs to match the [[OpenJDK]] licensing and be compatible with it. The licensing goal is however the same as in case of [[OpenJDK]]:
 +
 +
* if you write your application and execute it against standard [[JDK]] libraries - use the [[GPLwithClassPathException#.22CLASSPATH.22_EXCEPTION_TO_THE_GPL_VERSION_2|classpath exception]]
 +
* if you hack the [[Bck2Brwsr]] [[VM]] itself - follow the [[GPL]]v2 license
 +
 +
This kind of setup should give [[Java]] developers freedom to build their applications and distribute them under conditions of their choose, while making sure modifications, enhancements and improvements of the [[Bck2Brwsr]] [[VM]] code itself remain publicly available.
== Goals ==
== Goals ==
Line 7: Line 24:
Demonstrate that [[Java]] has benefits over [[JavaScript]] when creating larger [[HTML]]5 applications.
Demonstrate that [[Java]] has benefits over [[JavaScript]] when creating larger [[HTML]]5 applications.
-
Unlike other similar efforts, the goal of this project is '''not''' to execute any existing [[Java]] library. It is expected that libraries for the new, limited environment need to be specially designed.
+
Unlike other similar efforts, the goal of this project is '''not''' to execute any existing [[Java]] library. It is expected that libraries for the new, limited environment need to be specially designed. For example one cannot start new threads (as of [[Bck2Brwsr 0.13]] even there is a [[Bck2BrwsrThreading|proposal]] to do something with it).
== Demo ==
== Demo ==
-
There is a little [http://xelfi.cz/calc calculator demo] showing the first application that [[User:JaroslavTulach|I]] managed to get running in the browser. The application is packaged in a [[JAR]] file and the [[Bck2Brwsr]] [[VM]] loads necessary classes and transforms them into [[JavaScript]] on the fly.
+
The current flagship demo is [[MineSweeper]] running in the browser: http://xelfi.cz/minesweeper/bck2brwsr/
 +
As a memento it makes sense to keep in mind the little [http://xelfi.cz/calc calculator demo] showing the first application that [[User:JaroslavTulach|I]] managed to get running in the browser. The application is packaged in a [[JAR]] file and the [[Bck2Brwsr]] [[VM]] loads necessary classes and transforms them into [[JavaScript]] on the fly.
There is/was (relatively) enhanced [[Twitter]] demo showing various technologies including [[JSON]]P communication with the server. However as [[Twitter]] abandoned its authorization free [[API]] in May 2013, the communication with the server is broken.
There is/was (relatively) enhanced [[Twitter]] demo showing various technologies including [[JSON]]P communication with the server. However as [[Twitter]] abandoned its authorization free [[API]] in May 2013, the communication with the server is broken.
-
For [[JavaOne2013]] I developed a [http://xelfi.cz/JavaOneChess chess application] showing use of [[knockout.js]] from a [[Java]] code.
+
For [[JavaOne2013]] I developed a [http://xelfi.cz/JavaOneChess chess application] showing use of [[knockout.js]] from a [[Java]] code. See [[Knockout4Java]].
To demonstrate my geolocation API, I created another [http://xelfi.cz/kde/ Where are you?] demo.
To demonstrate my geolocation API, I created another [http://xelfi.cz/kde/ Where are you?] demo.
-
We also managed to port [[JavaFX]] to [[Bck2Brwsr]] and here is a [http://xelfi.cz/fishsim proof of that]. There is an overhead to load [[JavaFX]] scene graph [[API]], so excuse slight delay when downloading and booting the app. When running, the performance should be OK.
+
We also managed to port [[JavaFX]] to [[Bck2Brwsr]] and here is a [http://xelfi.cz/fishsim proof of that]. There is an overhead to load [[JavaFX]] scene graph [[API]], so excuse slight delay when downloading and booting the app. When finally running, the performance should be OK.
Line 29: Line 47:
== [[Bck2BrwsrViaCLI|Try It Yourself]]! ==
== [[Bck2BrwsrViaCLI|Try It Yourself]]! ==
-
It is simple to try [[Bck2Brwsr]]! The project skeleton is provided as [[Maven]] archetype. The use of the most recent one is described in [[Knockout4Java]] page. There is another one (with more experimental features) described at [[Bck2BrwsrViaCLI]].
+
It is simple to try [[Bck2Brwsr]]! The project skeleton is provided as [[Maven]] archetype. Follow steps described at [[Bck2BrwsrViaCLI]] or [[Knockout4Java]] tutorial.
== What is in New Releases? ==
== What is in New Releases? ==
-
=== Release [[Bck2Brwsr 0.8.1|0.8.1]] ===
+
=== Next Version [[Bck2Brwsr 0.55|0.55]] Will ... ===
-
 
+
-
{{:Bck2Brwsr 0.8.1}}
+
-
 
+
-
=== Release [[Bck2Brwsr 0.8|0.8]] ===
+
-
 
+
-
{{:Bck2Brwsr 0.8}}
+
-
 
+
-
=== Release [[Bck2Brwsr 0.7.2|0.7.2]] ===
+
{{:Bck2Brwsr 0.55}}
-
{{:Bck2Brwsr 0.7.2}}
+
=== Version [[Bck2Brwsr 0.54|0.54]] ===
 +
{{:Bck2Brwsr 0.54}}
-
=== Release [[Bck2Brwsr 0.7|0.7]] ===
+
=== Version [[Bck2Brwsr 0.53|0.53]] ===
-
{{:Bck2Brwsr 0.7}}
+
{{:Bck2Brwsr 0.53}}
-
=== Release [[Bck2Brwsr 0.6|0.6]] ===
+
=== Version [[Bck2Brwsr 0.52|0.52]] ===
-
{{:Bck2Brwsr 0.6}}
+
{{:Bck2Brwsr 0.52}}
-
=== Release [[Bck2Brwsr 0.5|0.5]] ===
+
=== Version [[Bck2Brwsr 0.51|0.51]] ===
-
{{:Bck2Brwsr 0.5}}
+
{{:Bck2Brwsr 0.51}}
-
=== Release [[Bck2Brwsr 0.4|0.4]] ===
+
=== Version [[Bck2Brwsr 0.50|0.50]] ===
-
{{:Bck2Brwsr 0.4}}
+
{{:Bck2Brwsr 0.50}}
-
== Done, not yet released ==
+
=== Older Releases ===
-
{{:Bck2Brwsr_0.9}}
+
See the full [[Bck2BrwsrChangeLog]] for historical information about older releases.
-
== TODO ==
+
== Wishlist ==
-
Although the system is capable to run and execute trivial applications, there remains tons of things to improve and fix. Any help is welcomed. Just let me know if something interests you:
+
The [[Bck2Brwsr]] system is capable to run and execute meaningful applications. Anyway there remains things to be improved and fixed. Any help is welcomed. Just let me know if something interests you:
-
* Use [[wikipedia:Closure_compiler#Closure_Compiler|Closure compiler]] to generate more compact code
+
* [[Debugger]] of [[Java]] (and not [[JavaScript]]) using properly generated source maps would be good
-
** Per individual libraries - [[ObfuscatePerLibrary]]
+
-
* Access to multipage via ''sammy.js'' or [http://millermedeiros.github.io/crossroads.js/ crossroads.js]
+
-
* Method and field overriding with various modifiers
+
-
* More reflection support (e.g. don't throw {{JDK|java/lang|SecurityException}} when allowed),
+
-
** No private method/field/constructor/class access
+
-
** Probably no field access
+
-
** May need constructor access
+
-
* [[Debugger]] of [[Java]] (and not [[JavaScript]] would be good)
+
-
* Performance benchmark Sci2000
+
-
* Investigate generating [[asm.js]] friendly code
+
-
* Generate [[Java]] wrappers for all [[HTML]]5 elements dynamically (Honza)
+
== Resources ==
== Resources ==
-
* Project page at [http://html.java.net html.java.net]
+
* [http://github.com/jtulach/bck2brwsr Project page] at GitHub
-
* [mailto:bck2brwsr@apidesign.org Mailing list]
+
* [mailto:bck2brwsr@apidesign.org Mailing list] and its [https://groups.google.com/d/forum/bck2brwsr archive]
-
* [http://source.apidesign.org/hg/bck2brwsr Source code]
+
* As of January 2017 [[I]] am moving the development to [https://github.com/jtulach/bck2brwsr GitHub] - (the original [http://source.apidesign.org/hg/bck2brwsr repository] remains read-only).
-
* [http://hudson.apidesign.org/hudson/view/bck2brwsr/ Hudson jobs]
+
* [https://maven.java.net/content/repositories/releases/org/apidesign/bck2brwsr/ Maven Repository at java.net]
* [https://maven.java.net/content/repositories/releases/org/apidesign/bck2brwsr/ Maven Repository at java.net]
* [[Bck2BrwsrJavadoc|Javadoc]]
* [[Bck2BrwsrJavadoc|Javadoc]]
-
* [http://java.net/bugzilla/buglist.cgi?product=html Bugs] are in java.net's bugzilla
 
[[Category:Bck2Brwsr]]
[[Category:Bck2Brwsr]]
[[Category:OpenSourceContribution]]
[[Category:OpenSourceContribution]]

Current revision

Bck2Brwsr VM is a Java virtual machine which is capable to take bytecode and convert it (either ahead-of-time e - e.g. during compilation - or just-in-time, e.g. in a browser) into appropriate JavaScript code which does the same thing. As a result one can write in Java, compile with JavaC, process it with Bck2Brwsr (usually via its Maven plugin, but possibly also directly via programmatic APIs) into a JavaScript file(s) that can be executed in any modern browser (IE 10 at least, please).

The easiest way to start is to play with a DEW - the Development Environment for Web. Just visit http://dew.apidesign.org/dew and edit, compile, run in a browser without installing anything or using (now banned) Java plugins.

The Bck2Brwsr project supports the generic and portable HTML/Java APIs as defined by NetBeans. Use them to run your application on desktop as a standalone application, as a NetBeans or Eclipse plugin or in a browser, via Bck2Brwsr VM.

Contents

Motivation

During my duties at JavaOne2012 my feeling (primed by observing various RSS feeds full of posts about something which ends .js) that Java is no longer as cool as it used to be straightened. It always starts by loosing interest of newcomers, targeting just a piece of the technology segment and soon once Good Technology becomes new COBOL. Can that happen to Java? Just read Is JavaScript the Future of Programming? and (if you like Java), you'll get scared. I decided to do something about that. I'd like to return my favorite programming language Bck2Brwsr.

Licensing

The code of Bck2Brwsr is heavily derived from OpenJDK source code (especially the libraries part, not the HotSpot part). Bck2Brwsr thus needs to match the OpenJDK licensing and be compatible with it. The licensing goal is however the same as in case of OpenJDK:

  • if you write your application and execute it against standard JDK libraries - use the classpath exception
  • if you hack the Bck2Brwsr VM itself - follow the GPLv2 license

This kind of setup should give Java developers freedom to build their applications and distribute them under conditions of their choose, while making sure modifications, enhancements and improvements of the Bck2Brwsr VM code itself remain publicly available.

Goals

Create small Java (check the Bck2BrwsrJavadoc) capable to boot fast and run in 100% of modern browsers including those that have no special support for Java.

Demonstrate that Java has benefits over JavaScript when creating larger HTML5 applications.

Unlike other similar efforts, the goal of this project is not to execute any existing Java library. It is expected that libraries for the new, limited environment need to be specially designed. For example one cannot start new threads (as of Bck2Brwsr 0.13 even there is a proposal to do something with it).

Demo

The current flagship demo is MineSweeper running in the browser: http://xelfi.cz/minesweeper/bck2brwsr/

As a memento it makes sense to keep in mind the little calculator demo showing the first application that I managed to get running in the browser. The application is packaged in a JAR file and the Bck2Brwsr VM loads necessary classes and transforms them into JavaScript on the fly.

There is/was (relatively) enhanced Twitter demo showing various technologies including JSONP communication with the server. However as Twitter abandoned its authorization free API in May 2013, the communication with the server is broken.

For JavaOne2013 I developed a chess application showing use of knockout.js from a Java code. See Knockout4Java.

To demonstrate my geolocation API, I created another Where are you? demo.

We also managed to port JavaFX to Bck2Brwsr and here is a proof of that. There is an overhead to load JavaFX scene graph API, so excuse slight delay when downloading and booting the app. When finally running, the performance should be OK.


Try It Yourself!

It is simple to try Bck2Brwsr! The project skeleton is provided as Maven archetype. Follow steps described at Bck2BrwsrViaCLI or Knockout4Java tutorial.

What is in New Releases?

Next Version 0.55 Will ...

Bck2Brwsr 0.55

Version 0.54

  • Support Class.getPackage() - #45
  • Better lambda support - #49
  • Ability to process pre-JDK1.6 class files - d2100cf02

Version 0.53

  • Bugfix for the Heartbeat support to use it only when connecting to localhost via HTTP

Version 0.52

  • Fastforward seven years and updating Closure compiler to version v20210601 - required bunch of fixes of unused variables, wrong code, etc.
  • Checking ClassCastException before calling lambda methods
  • Using importScripts when Bck2Brwsr is used in a Worker

Version 0.51

Version 0.51 of Bck2Brwsr VM is even better than Bck2Brwsr 0.50:

  • Important bugfixes for Gradle --continuous mode
  • Improved emulation of java.util.function and java.util.stream packages

Version 0.50

The Bck2Brwsr project has been updated to work with 2021 technologies:

No more RetroLambda. Instead of RetroLambda there is now an abstract IndyHandler interface with two implementations:

The removal of RetroLambda is a good thing - the system was fragile. It relied on reflection and internal behavior of JDKs. However, replacing it with homemade implementation is a request for regressions - finding and supporting all the corner cases is going to take some time. Thanks to Johan Vos, who managed to compile JavaFX with Bck2Brwsr transpiler and reported quite a few bugs. The likehood Bck2Brwsr 0.50 is going to work is now higher!


The easiest way to report an error is to enhance one of existing test-cases:

Thanks in advance for trying and helping Bck2Brwsr to get better!

Older Releases

See the full Bck2BrwsrChangeLog for historical information about older releases.

Wishlist

The Bck2Brwsr system is capable to run and execute meaningful applications. Anyway there remains things to be improved and fixed. Any help is welcomed. Just let me know if something interests you:

Resources

Personal tools
buy