Just reincarnate Plexus Compiler Component

Well I haven’t paid any attention to the project since 2008-Feb (shame on me!). But now I fixed it to support final released version of JavaFX 1.2 (which, thanks God, is available for Linux either).
I filled for Maven Central repository, so if everything is OK, it would be possible to build without references on the repository at sourceforge.net.

Just incubated an alfa version of Plexus Compiler Component for javafxc on Sourceforge

It allows to build Java FX code with Maven 2.
Take a look M2-javafxc project
It may not be considered as a full-featured version. But it working 🙂 Use but not abuse!

Just have requested a room to commit Maven plugin in OpenJFX

Well, actually there is also some issues…
It is an actually implementation of Plexus Compiler API for JavaFX. This is very easy to get it working (will just require to have some more params specific to JavaFX). I just “forked” from JavacCompiler of Plexus.
But what about license? Plexus code is under MIT and Apache licenses, while OpenJFX is under GNU. Could it actually survive?
It would be good to have artifact repository with all versions of compiler, runtime and Scenegraph. Where? Again how licenses should be managed?
Minor: what version, artifactId and groupId should OpenJFX *.jar get? It is slightly more than just a naming convention…

the request

Date: Wed, 06 Feb 2008 15:32:33 +0200
From: Alexander Zynevich <zynevich@mail.ru>
Content-Type: text/plain; char set=ISO-8859-1; format=flowed
Subject: Java FX with Maven and Ant


Tom,
	playing with Maven a bit I have found that it is quite easy to add one 
more "JavaC"-like compiler component to Maven, and I wrote one. It is 
very draft, but working. I could contribute. Is it acceptable to have it 
somewhere within openjfx.dev.java.net site? Say, as a subproject  of 
openjfx, sibling of openjfx-compiler? I mean if I submit 
request-for-proj, d'you approve? :)

PS: for those who are interesting in Maven-javafxc:
POM will looks like:
<project xmlns="http://maven.apache.org/POM/4.0.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>net.java.dev.openjfx</groupId>
   <artifactId>testjfx</artifactId>
   <packaging>jar</packaging>
   <version>1.0-SNAPSHOT</version>
   <name>testjfx</name>
   <url>http://maven.apache.org</url>
   <dependencies>
     <dependency>
       <groupId>net.java.dev.openjfx</groupId>
       <artifactId>javafxrt</artifactId>
       <version>1.0-SNAPSHOT</version>
       <scope>compile</scope>
     </dependency>
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <version>3.8.1</version>
       <scope>test</scope>
     </dependency>
   </dependencies>
   <build>
       <plugins>
           <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-compiler-plugin</artifactId>
               <configuration>
                   <compilerId>javafxc</compilerId>
                   <include>**/*.fx</include>
               </configuration>
               <dependencies>
                   <dependency>
                       <groupId>net.java.dev.openjfx</groupId>
                       <artifactId>openjfx-compiler-javafxc</artifactId>
                       <version>1.0-SNAPSHOT</version>
                   </dependency>
               </dependencies>
           </plugin>
       </plugins>
   </build>
</project>

output when building from NB6.0:
WARNING: You are running Maven builds externally, some UI functionality 
will not be available.
Executing:/usr/share/apache-maven-2.0.8/bin/mvn --errors clean install
+ Error stacktraces are turned on.
Scanning for projects...
------------------------------------------------------------------------
Building testjfx
    task-segment: [clean, install]
------------------------------------------------------------------------
Deleting directory /home/alex/NetBeansProjects/testjfx/target
Using default encoding to copy filtered resources.
Downloading: 
http://people.apache.org/repo/m2-snapshot-repository/net/java/dev/openjfx/javafxc/1.0-SNAPSHOT/javafxc-1.0-SNAPSHOT.pom
Compiling 2 source files to 
/home/alex/NetBeansProjects/testjfx/target/classes
Using default encoding to copy filtered resources.
Nothing to compile - all classes are up to date
No tests to run.
Building jar: 
/home/alex/NetBeansProjects/testjfx/target/testjfx-1.0-SNAPSHOT.jar
Installing 
/home/alex/NetBeansProjects/testjfx/target/testjfx-1.0-SNAPSHOT.jar to 
/home/alex/.m2/repository/net/java/dev/openjfx/testjfx/1.0-SNAPSHOT/testjfx-1.0-SNAPSHOT.jar
------------------------------------------------------------------------
BUILD SUCCESSFUL
------------------------------------------------------------------------
Total time: 7 seconds
Finished at: Wed Feb 06 15:23:57 EET 2008
Final Memory: 23M/41M
------------------------------------------------------------------------

Tom Ball wrote:
> Peter Pilgrim wrote:
>>> The task is as much like the javac Ant task as practical.  When using in
>>> your own projects, be sure to specify the bootclasspath argument
>>> (especially on Macs) as we are using new versions of javac than what's
>>> released.
>>
>> Therefore it should be runnable from Maven as a `maven-antrun-plugin'
>> with some pushing.
> 
> Good to know -- this answer probably belongs in an FAQ somewhere.
> 
>>> Any improvements and other suggestions are appreciated, as none of us
>>> claim to be Ant experts -- we're just Ant users like most other Java
>>> developers.
>>
>> Neither am I an Ant or Maven expert. Thanks for your input.
>> Do you have an opinion on separate source code and classes folders?
>> The maven standard is to use (at least for Java is):
>>
>> <YOUR-PROJECT>/src/main/java
>>
>> which appears in <YOUR-PROJECT>/target/classes
>>
>> For Unit testing it follows a similar pattern
>>
>> <YOUR-PROJECT>/src/test/java
>>
>> which appears in <YOUR-PROJECT>/target/test-classes
>>
>> Would you mix JavaFX and Java code together or would you encourage
>> separate source folder for each language.
>>
>> <YOUR-PROJECT>/src/main/javafx
>> which appears in <YOUR-PROJECT>/target/classes
> 
> Personally, I prefer keeping all build artifacts separate from the 
> project source, so that full cleanup involves just deleting one or more 
> generated directories such as build, dist, etc.  The compiler is 
> currently following the naming conventions of the javac team so we can 
> more easily work together, but other projects should be free to follow 
> Maven, Eclipse, NetBeans, or any other naming convention that makes 
> sense for that project.
> 
> I think JavaFX Script, Java, Jython, JRuby, and any other JVM compiled 
> language should be grouped by functionality rather than language, so 
> everything that belongs in one package shouDate: Wed, 06 Feb 2008 15:32:33 +0200
From: Alexander Zynevich <zynevich@mail.ru>
Content-Type: text/plain; char set=ISO-8859-1; format=flowed
Subject: Java FX with Maven and Ant


Tom,
	playing with Maven a bit I have found that it is quite easy to add one 
more "JavaC"-like compiler component to Maven, and I wrote one. It is 
very draft, but working. I could contribute. Is it acceptable to have it 
somewhere within openjfx.dev.java.net site? Say, as a subproject  of 
openjfx, sibling of openjfx-compiler? I mean if I submit 
request-for-proj, d'you approve? :)

PS: for those who are interesting in Maven-javafxc:
POM will looks like:
<project xmlns="http://maven.apache.org/POM/4.0.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>net.java.dev.openjfx</groupId>
   <artifactId>testjfx</artifactId>
   <packaging>jar</packaging>
   <version>1.0-SNAPSHOT</version>
   <name>testjfx</name>
   <url>http://maven.apache.org</url>
   <dependencies>
     <dependency>
       <groupId>net.java.dev.openjfx</groupId>
       <artifactId>javafxrt</artifactId>
       <version>1.0-SNAPSHOT</version>
       <scope>compile</scope>
     </dependency>
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <version>3.8.1</version>
       <scope>test</scope>
     </dependency>
   </dependencies>
   <build>
       <plugins>
           <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-compiler-plugin</artifactId>
               <configuration>
                   <compilerId>javafxc</compilerId>
                   <include>**/*.fx</include>
               </configuration>
               <dependencies>
                   <dependency>
                       <groupId>net.java.dev.openjfx</groupId>
                       <artifactId>openjfx-compiler-javafxc</artifactId>
                       <version>1.0-SNAPSHOT</version>
                   </dependency>
               </dependencies>
           </plugin>
       </plugins>
   </build>
</project>

output when building from NB6.0:
WARNING: You are running Maven builds externally, some UI functionality 
will not be available.
Executing:/usr/share/apache-maven-2.0.8/bin/mvn --errors clean install
+ Error stacktraces are turned on.
Scanning for projects...
------------------------------------------------------------------------
Building testjfx
    task-segment: [clean, install]
------------------------------------------------------------------------
Deleting directory /home/alex/NetBeansProjects/testjfx/target
Using default encoding to copy filtered resources.
Downloading: 
http://people.apache.org/repo/m2-snapshot-repository/net/java/dev/openjfx/javafxc/1.0-SNAPSHOT/javafxc-1.0-SNAPSHOT.pom
Compiling 2 source files to 
/home/alex/NetBeansProjects/testjfx/target/classes
Using default encoding to copy filtered resources.
Nothing to compile - all classes are up to date
No tests to run.
Building jar: 
/home/alex/NetBeansProjects/testjfx/target/testjfx-1.0-SNAPSHOT.jar
Installing 
/home/alex/NetBeansProjects/testjfx/target/testjfx-1.0-SNAPSHOT.jar to 
/home/alex/.m2/repository/net/java/dev/openjfx/testjfx/1.0-SNAPSHOT/testjfx-1.0-SNAPSHOT.jar
------------------------------------------------------------------------
BUILD SUCCESSFUL
------------------------------------------------------------------------
Total time: 7 seconds
Finished at: Wed Feb 06 15:23:57 EET 2008
Final Memory: 23M/41M
------------------------------------------------------------------------

Tom Ball wrote:
> Peter Pilgrim wrote:
>>> The task is as much like the javac Ant task as practical.  When using in
>>> your own projects, be sure to specify the bootclasspath argument
>>> (especially on Macs) as we are using new versions of javac than what's
>>> released.
>>
>> Therefore it should be runnable from Maven as a `maven-antrun-plugin'
>> with some pushing.
> 
> Good to know -- this answer probably belongs in an FAQ somewhere.
> 
>>> Any improvements and other suggestions are appreciated, as none of us
>>> claim to be Ant experts -- we're just Ant users like most other Java
>>> developers.
>>
>> Neither am I an Ant or Maven expert. Thanks for your input.
>> Do you have an opinion on separate source code and classes folders?
>> The maven standard is to use (at least for Java is):
>>
>> <YOUR-PROJECT>/src/main/java
>>
>> which appears in <YOUR-PROJECT>/target/classes
>>
>> For Unit testing it follows a similar pattern
>>
>> <YOUR-PROJECT>/src/test/java
>>
>> which appears in <YOUR-PROJECT>/target/test-classes
>>
>> Would you mix JavaFX and Java code together or would you encourage
>> separate source folder for each language.
>>
>> <YOUR-PROJECT>/src/main/javafx
>> which appears in <YOUR-PROJECT>/target/classes
> 
> Personally, I prefer keeping all build artifacts separate from the 
> project source, so that full cleanup involves just deleting one or more 
> generated directories such as build, dist, etc.  The compiler is 
> currently following the naming conventions of the javac team so we can 
> more easily work together, but other projects should be free to follow 
> Maven, Eclipse, NetBeans, or any other naming convention that makes 
> sense for that project.
> 
> I think JavaFX Script, Java, Jython, JRuby, and any other JVM compiled 
> language should be grouped by functionality rather than language, so 
> everything that belongs in one package should reside in one directory. 
> If the tools can't figure out the difference between those file types, 
> then the tools need to be improved, but happily all I've tried seem to 
> work fine.  Again, that's just my personal opinion, as teams should 
> define the conventions that make sense in their context.
> 
> Tom
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@openjfx.dev.java.net
> For additional commands, e-mail: users-help@openjfx.dev.java.net
> 
> 



ld reside in one directory. 
> If the tools can't figure out the difference between those file types, 
> then the tools need to be improved, but happily all I've tried seem to 
> work fine.  Again, that's just my personal opinion, as teams should 
> define the conventions that make sense in their context.
> 
> Tom
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@openjfx.dev.java.net
> For additional commands, e-mail: users-help@openjfx.dev.java.net
> 
> 




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");
	%>
	<html>
<%
	if ( (!"".equals(title) {
%>
		<title><%= escape(title) %></title>
<%
	}
	else {
%>
		<title>Home Page</title>
<%

	}
%>
	...

-- BECOMES --
	out.write("<html>
		<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>"
			} 
		}</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) {
			t.commit();
		}
		else {
			t.rolback();
		}
		// 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)) {
			x++
		}
		else {
			x++;
			null
		}
	}

-- OR LESS TRICKY --
	var primesUpTo100 = while(x <= 100) {
		if (isPrime(x)) {
			var prime = x;
			x = x + 1;
			prime
		}
		else {
			x = x + 1;
			null
		}
	}

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
https://openjfx-compiler.dev.java.net/servlets/ReadMsg?list=dev&msgNo=1844
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
http://java.sun.com/javase/6/docs/api/java/lang/String.html#codePointAt(int)

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!";
}

System.out.println(ca.s.length());
var c = ca.s.charAt(0);
System.out.println(c.getClass());

it prints:

6
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?

Well,
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");
x.setWidth(300);
// 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:
   @Override;
   protected init() {
       setTitle("Ch1 Demo");
       setWidth(300);
   }
   ... 
}

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");
      super.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 ant.zip 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 ant.zip 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"/>
        </unzip>
        <!--delete file="${ant.zipfile}" /-->
    </target>

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.