Yet Another Maven plugin for Eclipse

A friend of mine found
looks like it is an alternative to famous .
However we failed to run it 🙂 on Eclipse 3.3.1.x and have no time for experiments.

Proposal for {}-expressions in JavaFX

I have wrote a proposal to send it to openjfx-compiler project… But I found that some of features I propose is already implemented in the language… see upcoming post. I feel my self as Gray being overtaking by Bell 😦 But positive side is that I am on the same page with people creating this language 🙂
Anyway that is what I wanted to sent to openjfx-compiler mail.list:

Proposal to have {} to evaluate to some value.

I was inspired for this idea by if-then-else construct.
As far as I remember it was the old ALGOL-60 language which enables “IF cond THEN v1 ELSE v2” first, and that time it looks exactly the same syntax.
However I think it would only look OK in Pascal or Modula-2, but not in JavaFX.
Because JavaFX tends to be expression language I propose to have { } construct to evaluate to some value. How it could help?
1. if-then-else will not be needed any longer one could write:

	var result = if (operation = "-") {x-y} else {x+y}
	or even better example:
	var result = if (operation = "-") {x-y} else if (operation = "+") {x + y} else if (operation = "*") {x * y} else if (operation ="/") { if(y == 0) {throw DivisionByZeroException{};} else {x/y}};

2. we could write as simple as (w/o return):

	function mediana(a: Integer, b:Integer) {
		(a + b) / 2 // NOTE: semicolon (;) to be ommited

3. we could put some additional computation in { } only the last one operator(expression) in { } will be a result expression.

	 * Overflow protected version of mediana
	function mediana(a: Integer, b:Integer) {
		var sumOfHalves = a/2 + b/2;
		var remainders = a%2 + b%2;
		sumOfHalves + remainders

4. I have some ideas about JavaFX variant of servlets/JSP. Look! how pretty could look {}-expression in the strings, it could substitute both JSP’s expression (<%= %>) and JSP’s scriptlet (<% %>):

		String title = request.getAttribute("title");
	if ( (!"".equals(title) {
		<title><%= escape(title) %></title>
	else {
		<title>Home Page</title>


			var title = request.getAttribute("title");
			if ("" <> title) {
				"<title>{escape(title)}</title>" //NOTE: this "if" is an "if" between 2 string expressions!
			else {
				"<title>Home Page</title>"


5. the only exception where there should not be {}-expression is finally {}-block of try-catch-finally:

	transactionOK = false;
	try {
		transactionOK = true;
		someValue // some expression
	catch(SomeExceptionToHandle e) {
		transactionOK = true;
		someOtherValue // some expression
	catch(SomeCriticalExpection e) {
		throw AnotherException{};	
        finally {
		if (treansactionOK) {
		else {
		// here expression may not be set

6. (OPTIONALY) for cycles for and while, evaluation of {}-block may automaically create sequence:

	var primesUpTo100:Integer[] = while(x <= 100) {
		if (isPrime(x)) {
		else {

	var primesUpTo100 = while(x <= 100) {
		if (isPrime(x)) {
			var prime = x;
			x = x + 1;
		else {
			x = x + 1;

7. The similair feature exists in C language: it is comma operator (,) however its idea is vice-versa — to unstructurize code and write everithing in one line: y = (x=1, z=2, x*z);

Strings in terms of codepoints? Kill Java char type!

Wrote a message to dev@openjfx-compiler
copy it here:
I think, JavaFX should have a separate String class. Which should be
automatically converted to Java’s string and back. Why?

In Java 6 the was introduced idea of code points, because Java strings
is no longer a Unicode strings (currently Unicode character does not fit
16 bit char type. So Java’s native encoding is no longer Unicode but
UTF-16. This means that char type is just 16bit and is not a character.
The charactet(one visible sign) is a “code point”:
see method
public int codePointAt(int index) in

SO I propose to have special class for String in JavaFX.

package javafx.lang;
class String {
	length() : Integer; // Actually retuns Java's codePointCount()
	charAt(i: Integer) : String; // Actually returns Java's codepoint
	... + and all useful methods from Java's String.
         ... - all methods for code points
         ... + may be some methods to work with char's but make their 
names so that anybody understands they are auxillary

After introduction of code points existing Swing code should actually be
rewritten to work in terms of code points. Because if you have input
field for username as 8 characters, the user expects he/she could enter
8 real charaters. But if you apply limit of 8 to
java.lang.String.length() you will allow to enter only 4 of some new
Unicode characters from extended set. I think it would be good if JavaFX
users forgot about char and knew nothing about difference in length()
and codePointsCount().

Currently I see that JavaFX only partially hides presence of Character type:

var ca = ClassA {
     s: "Hello!";

var c = ca.s.charAt(0);

it prints:

class java.lang.Character

however because idea of JavaFX to have only Integer Number String
Boolean i would expect c to be of type Integer. But this is not so.

Also may be having separate String class will allow to have not nullable
string attribute? As we currently have for Integer, Number and Boolean?

Please consider!

Could JavaFX has the common syntax for object literal, anonymous classes, and AOP?

I have one idea, I could not say it is stupid or not, but looks amazing.
What the following construct is?

Frame {
    title: "Ch1 Demo"
    width: 300
    height: 250
    visible: true

Well it is equivalent of:

x = Frame;
x.title= "Ch1 Demo"
x.width= 300
x.height= 250
x.visible= true

or Java’s equivalent (informal, because javafx.ui.Frame is not directly avalable in Java):

Frame x = new Frame();
x.setTitle("Ch1 Demo");
// and so on

Of course this is just one of the possible equiv in Java… “Straight forward” I could say…

But I begin to think about alternative equivalents:

Frame x = new Frame() {
   // there is no way to add new constructor or initialization code, but let us imagine there is overloadable init() method called from Frame constructor:
   protected init() {
       setTitle("Ch1 Demo");

So I propose the following:
Let the object literal construct to allow also method overriding, adding triggers and so on, just for example:
Let’s assume our frame has paint() method (bad example I know — but let assume such method exists). So let it be possible:

Frame {
    title: "Hello, Wolrd!" on replace {
      throw ModificationProhibitedException; // we prohibit further modification of attribute
    width: 300;
    // and so on
    paint() {
      System.out.println("before paint");
      System.out.println("after paint");

Implementation of such feature may be:
1. As I have already introduced via a kind of “anonymous” classes.
2. Via proxifying original class (using mechanism similar to java.lang.reflect.Proxy or LIBGC).

Of course if there is no method overriding or trigger, then object literal will be as simple as object initialization.

OK let’s assume we have variant 2.

Then it would be possible to extend object literal construct to the following.
Say we already have:

var frame = Frame {title: "Name"};

if we allow following syntax:

frame { // from small letter -- because we would like the following will be applied on specified variable only:
     title on replace {
         System.out.println("title is changed :) ");
     paint() {
         ... // we could intercept paint() method.

thus it would be possible to assign a pretty a lot of attributes with one shot:

frame {
    title: "new title"; // frame.title = "new title"
    width: 200; // frame.width = 200;

So varialble{} will resemble PASCAL’s WITH operator 🙂 in such usage scenario.
I could evolve this idea even further
we could treat simple block of code in curly brackets as

Void {

because void is nothing this is just a piece of code… — there is no attribute or method to reference.

How all this may be implemented?
Well I think one of the possible way: for each object to have a data record + some “proxy” over it. This proxy will register overriding original methods and triggers… And constructions like frame { … } should be freely casted to original Frame class and may be “frame instanceof Frame” should return true (not like proxies in Java).

What do you think, mates?

Made JavaFX compiled, finally…

Contributors and beta-testers are welcomed to javafx project.
However building process is not so easy as someone may expect…

Is your ADSL fast?

I am lucky to have 256mbit/s…
If you just checkout and start to build it you may notice that it starts to download required tools in Maven style but using plain <get> of ANT. Interesting that it fetchs JUnit, ANT (itself!) and ANTLR and some other libs.
In my particular case build was failed because was not expanded and it was not expanded because there is only 4.5 MB of 11MB of ZIP file were downloaded. I solved it the following way I download from the mirror, which got me all 11MB. (Seems that apache distributive server has a timeout on downloads which my 256mbit/s does not fit)
I changed:

    <target name="ant" depends="prepare">
        <!-- get src="${ant.url}" dest="${ant.zipfile}" /-->
        <unzip src="${ant.zipfile}" dest="${ant.dir}">
            <patternset includes="**/ant.jar"/>
            <mapper type="flatten"/>
        <!--delete file="${ant.zipfile}" /-->

And run bootstrap.xml in the openjfx-compiler project manualy…
Hopefully all other artifacts where downloaded with no problems.
Those who still has 56K should download everything manually and run bootstrap manually, because if it fails it starts from the very beginning. Be accurate and comment out all “delete file” either otherwise ANT will/may delete your artifacts.

Get more memory to your NB

I forgot to mention that you need NetBeans to build all the stuff.
Most probable that with default settings it will fail to run because of out-of-memory error.
Go to /usr/local/netbeans-6.0/etc and edit netbeans.conf (note: is actually one line, I just wrapped it for readability):

netbeans_default_options="-J-Dorg.netbeans.modules.tomcat.autoregister.token=1200072112148 -J-Dorg.netbeans.modules.tomcat.autoregister.catalinaHome=\"/usr/local/apache-tomcat-6.0.14\" 
-J-Dcom.sun.aas.installRoot=\"/usr/local/glassfish-v2\" -J-client -J-Xss2m 
-J-Xms200m -J-XX:PermSize=32m 
-J-Xmx600m -J-Xverify:none -J-Dapple.laf.useScreenMenuBar=true"

So I requested 200MB of starting heap size and 600MB of limit. I didn’t investigated how much is actually required, but this limits were enough.

After that I got it successfully compiled and famous bubble test runs, it produces 96fps on my Fedora 8 (built-in Intel 915 GA and Intel T5500 processor — Dual Core).

That is all for now.

Втихоря спешно клепается новая версия JavaFX

… а по сути дела другой язык. Где-то в новостях проскакивало, что сам старина Гослинг взялся за JavaFX. Очень может быть. некоторые вещи кардинально пересмотрены. Что обидно; ни где, ни слова об этом нет. Короче жизнь кипит в это и по email листам видно.

How to escape curly brackets (braces) in JavaFX? I know how, but this is dull…

Well I need to write something like:

System.out.println("NewClass{} is just a way to call NewClass constructor");

of course it fails to compile because it expects some code in the curly brackets, then it would execute it and replace curly bracketed code with execution result. How to avoid it?
I found one way to escape it:

System.out.println("NewClass\u007B\u007D is just a way to call NewClass constructor");

However it looks pretty dull (as if I tried to embed some Unicode charter which does not fit current encoding or hard to find on keyboard 🙂 )
May be there is a better way to escape? (Octal and hex escapes are also considered dull 🙂 )
\{ \} is not working, alas…