- A Concurrent Affair - https://www.concurrentaffair.org -

Demo of DrJava/HJ

In today’s DrJava/Habanero meeting, Vincent, Jarred and I presented a demo of DrJava/HJ [1] to Jack Dennis of MIT. Generally, we were quite pleased how we could just re-build Habanero Java and DrJava, and get a working version with the newest features from both packages.

We also noticed a few problems, of course. Perhaps most critically, when using the HJ compiler from within DrJava, the compiler uses the wrong directories when it generates class files for classes not in the default package [2].

I fixed part of that bug. The compiler adapter was ignoring the destination directory passed to the HJ compiler adapter. Now, if you create a project and set a build directory, the class files will end up in the right place. I have committed this fix into the DrJava trunk and also into the drjava-hj branch.

I didn’t fix the problem (a) if there is no build directory set, or (b) if we are not in project mode. This is something that I think should be fixed in the HJ compiler, because it doesn’t behave the same way javac behaves: If you invoke javac and don’t give it a destination directory, it will generate the class files in the same directory where the source files are. The HJ compiler generates the class files in the current directory.

Example:

[cci]javac src/HelloWorld.java[/cci] generates the class file src/HelloWorld.class.
[cci]hjc src/HelloWorld.hj[/cci] generates the class files HelloWorld.class, HelloWorld$0.class, and HelloWorld$Main.class. in the current directory, not in src.

I hope the HJ team will agree this is a change that should be made in the HJ compiler.

Furthermore, we noticed again that compiler error messages aren’t displayed in DrJava’s Compiler Output pane [3]. We also noted that we cannot call methods directly from the Interactions pane [4]: We have to use the [cci]hj[/cci] or [cci]run[/cci] commands, otherwise the class loader isn’t properly set up. We should at least come up with a better error message than throwing an exception:

[ccN]Welcome to DrJava. Working directory is /Users/mgricken/bin/hj.release/examples
> new FibFuture().fib(10)
java.lang.NullPointerException
at hj.lang.Runtime.here(Runtime.java:317)
at hj.lang.Object.(Object.java:44)
at FibFuture.(FibFuture.hj)[/ccN]

Interestingly, we can call Mint methods from the Interactions pane, we just cannot use the new syntax elements in Mint, brackets and escape.
[ccN]Welcome to DrJava. Working directory is /Users/mgricken/Documents/Research/Mint/java-mint/trunk/langtools/mintTest
> import edu.rice.cs.mint.runtime.*
> Code c = DrJavaInteractions.makeCodeInt(5)
> c
<| ((5)) |>
> Code cTo10 = DrJavaInteractions.spower(c, 10)
> cTo10
<| (((5)) * (((5)) * (((5)) * (((5)) * (((5)) * (((5)) * (((5)) * (((5)) * (((5)) * (((5)) * (1))))))))))) |>
> cTo10.run()
9765625[/ccN]

[5] [6]Share [7]