Another Eclipse Compiler Bug

I got compiling in DrJava using the Eclipse compiler to work last night, except that the errors never provided a source location. I thought this was because I hadn’t set the source path in the file manager, but it turned out that is not the issue. There is another bug in the Eclipse compiler: The developers use a file name in a place where a class name is expected, and because of that, the look-up of the source location always fails.

I filed a bug report for it: Bug 308256 – DiagnosticListener always supplies Diagnostic.getSource()==null

Build Identifier: ecj-3.6M6.jar

When compiling with a DiagnosticListener and encountering an error, the
provided Diagnostic always returns null for the getSource()
call.

This is because originatingFileName is being passed to
JavaFileManager.getJavaFileForInput, even though the method expects a class
name. For example, “/home/username/temp/Foo.java” is being passed as a class
name, not “Foo”.

@Override
public JavaFileObject getSource() {
try {
if (EclipseCompilerImpl.this.fileManager.hasLocation(StandardLocation.SOURCE_PATH)) {
return EclipseCompilerImpl.this.fileManager.getJavaFileForInput(
StandardLocation.SOURCE_PATH,
new String(originatingFileName),
JavaFileObject.Kind.SOURCE);
}
} catch (IOException e) {
// ignore
}
return null;
}


Instead of using getJavaFileForInput, which expects a class name, you could use
getJavaFileObjects, which works for a file name.

Reproducible: Always

Steps to Reproduce:
1. Just compile code using a DiagnosticListener
2. Encounter an error in a Java file.
3. Look at the return value of Diagnostic.getSource(), it is always null.

Now I don’t quite know what to do. Should I fix this bug locally and use a modified version of the Eclipse compiler in DrJava, until this bug gets fixed by the Eclipse people?

Share
Posted in DrJava | Leave a comment

Print This Post Print This Post  

Eclipse Bug in Error Reporting

I’m working on integrating the Eclipse Java Compiler into DrJava (see feature request), but error reporting doesn’t work correctly yet.

After some confusion during debugging, I found out that this is because of an Eclipse bug (Eclipse bug report 290470):

In revision 1.45 of DefaultProblemFactory.java, the createProblem method was overloaded to include an elaborationId. But until revision 1.11 of EclipseCompilerImpl.java, the new method wasn’t overridden.

The bugfix isn’t in the in the 3.5.2 release yet, but it is in the 3.6M6 milestone. I guess I will use that for now and then update to release 3.6 when it’s available.

Share
Posted in DrJava | 1 Comment

Print This Post Print This Post  

Short Summary

The last few days summed up:

  • Happy Easter!
  • Still working on propagating reachability-from information into the methods. That should allow me to do a simple run-once-run-many analysis.
  • I noticed my scanner was broken too, not just the power supply.
  • FedEx delivered my new scanner, a Canon CanoScan LiDE100, on Saturday, and it rocks.
  • I returned the power supply to RadioShack. Thanks for the loan. I love America.
  • Congratulations to a very nice MS defense, Jun.
Share
Posted in Concurrent Unit Testing, Uncategorized | Leave a comment

Print This Post Print This Post  

Soot May-Happen-in-Parallel Analysis

I got Soot’s “may happen in parallel” (MHP) analysis to work, but only on a very small, completely unrealistic example which I used to test my “shared volatile” code (source below). Even for this, I needed to set the heap size to 2 GB (which, if I remember correctly, won’t work on Windows machines). Anything a little bit bigger either exhausted
memory or caused the JVM garbage collector crash.

They must be horribly inefficient with their static analysis. In one of the theses I read today, the biggest benchmarks had 3,800 lines of code. Maybe I am doing something wrong, because they used 1.5 GB heap, but as of now I have doubts their analysis scales to real applications like DrJava.

Furthermore, Soot’s MHP analysis doesn’t take the event thread into account, but this is probably a smaller issue.

package testers.volatileVarsThread;

public class VolatileVarsThread {
public static volatile int vsField;
public static int sField;
public static volatile int vsField_notShared;
public static int sField_notShared;

public static void main(String[] args) {
doStuff();
try {
new Thread(new Runnable() {
public void run() {
++vsField;
++sField;

System.out.println("Foo");
int i = doStuff() + doStuff();
System.out.println("i = "+i);

I c = new C();
c.doSomething();
}
}).start();
}
catch(java.lang.Exception e) { }
++vsField_notShared ;
++sField_notShared;
B b = new B();
b.doSomething();
}

public static int doStuff() {
return new A().foo() + 2;
}
}

class A {
public int foo() {
return bar() + 1;
}

public int bar() {
return 123;
}
}

interface I {
public void doSomething();
}

class B implements I {
public volatile int vField_notShared;
public int field_notShared;
public volatile int vField_notSharedButDynamicTarget;
public int field_notSharedButDynamicTarget;
public B() {
++vField_notShared;
++field_notShared;
}
public void doSomething() {
++vField_notSharedButDynamicTarget;
++field_notSharedButDynamicTarget;
System.out.println("B.doSomething");
}
}

class C implements I {
public volatile int vField = 3;
public int field = 4;

public void doSomething() {
vField = 0;
field = 0;
System.out.println("C.doSomething");
}
}

Share
Posted in Concurrent Unit Testing | Leave a comment

Print This Post Print This Post  

Subversion Word Diff

While looking for information on Soot, I found this little gem here by Chris Pickett: swd, Subversion Word Diff.

This is perfect for writing LaTeX papers in a group. For example, when I do an svn diff on our Mint paper, I might get something like this:

 A key issue for MSP is type safety, which ensures statically that all
-programs generated at runtime will be well-formed. Unfortunately,
-although it is known how to ensure type safety for MSP in the purely
-functional setting \cite{taha98,taha03,calcagno04}, it remained an
+programs generated at runtime will be well-formed. Although it had
+been known how to ensure type safety for MSP in the purely functional
+setting \cite{taha98,taha03,calcagno04}, it previously remained an
 open challenge how to extend this guarantee to mainstream languages
 such as Java.  In particular, standard features of mainstream
 languages

When I use Chris’ svn wdiff, I get something much cleaner:

A key issue for MSP is type safety, which ensures statically that all
programs generated at runtime will be well-formed. Unfortunately,
although Although it is had
been known how to ensure type safety for MSP in the purely functional
setting \cite{taha98,taha03,calcagno04}, it previously remained an
open challenge how to extend this guarantee to mainstream languages

This could have been really useful during editing before submitting the camera-ready version.

Share
Posted in Uncategorized | Leave a comment

Print This Post Print This Post  

RadioShack Power Supply

I bought a RadioShack 12 V, 1.5A power supply today to replace the one that died yesterday. I had written down the voltage and current, but hadn’t bothered with the actual tip because I expected to just buy the cheapest power supply, cut and strip the wires and attach the tip from the original power supply.

I forgot that RadioShack has the “adaptaplug” power supplies, and that I’d get one tip for free. I just picked a tip from memory.

I picked right.

Share
Posted in Uncategorized | Leave a comment

Print This Post Print This Post  

My Favorite New Bash Command Line

A while ago I found an article entitled Top Ten One-Liners from CommandLineFu Explained, and I liked the example to quickly create backup files. Well, today I had some kind of Perforce problem after I renamed a couple of files, and I couldn’t submit the changelist, but I also wasn’t allowed to resolve anything.

So I decided to use my new CommandLineFu to make a backup, revert, checkout and copy the backup back over. It was amazingly simple:

cp FindReachableMethods.java{,.save}
p4 revert FindReachableMethods.java
p4 edit FindReachableMethods.java
mv FindReachableMethods.java{.save,}

Line 1 copies FindReachableMethods.java to FindReachableMethods.java.save. The {,.save} part expands to two arguments, the first one being just the preceding file name, the second the preceding file name with .save attached. In line 4, I move the files, but in the opposite direction.

Share
Posted in Uncategorized | Leave a comment

Print This Post Print This Post  

ClassLoader.definePackage

I received a bug report yesterday that Class.getPackage() wasn’t working for user-defined classes and classes written in the Interactions Pane:

I was trying to run one of our assignment projects on DrJava and kepts getting a NullPointerException because getPackage() returns null. Corky said it was best to contact you about this.

To reporduce:
1. Load the attached project in DrJava
2. Run the following on the interactions pane:
new edu.rice.comp211.laundry.Main().getClass().getPackage()

You’ll see null get printed.

This was a bit confusing for me because of several quick tests that I made: I tested it in the default package, and for the default package, the return value of Class.getPackage() is supposed to be null. I also compared DrJava’s Interactions Pane to running programs in DrJava using the “Run” button. I should have compared it to running programs on the command line.

I hadn’t heard of having to call ClassLoader.definePackage before. Somehow, it had never been mentioned in any of the documents I had read about class loaders. The documentation seems to say that
package information is optional (“It may be null if no package information is available from the archive or codebase.”).

I figured out that we needed to call getPackage() in the class loader and check if it is null. If it is, and we are defining a class outside the default package, then we need to define a package by calling definePackage() before we call defineClass() (“Packages must be created before the class is defined”).

I just don’t understand why this isn’t done automatically with default values. My call looks like this:

definePackage(packageName, null, null, null, null, null, null, null);

There isn’t any more information being provided, except to say that this package exists. After a class in the package has been loaded, a package cannot be defined anymore, so there is no reason for not defining a package without information.

Share
Posted in DrJava, Ramblings | Leave a comment

Print This Post Print This Post  

UPS Went Poof

This morning, my uninterruptable power supply (UPS) for my computer went poof. It really made that sound, and then there was a chemical smell in the room. It had acted up a few times in the last couple of months, but I thought the worst that could happen was that my computers would lose power. Well, this smelled a bit more dangerous, so I decided to replace it. I already picked up a new UPS from Office Depot (who wanted to sell it in the store for $99.99, but I matched it to $89.99 on the website) and it’s charging, but I haven’t switched the old one out, which is unplugged now. I didn’t want to risk an electrical fire while I was at work.

Update

It seems like there was another casualty: The reverse converter that I had been using to power the German flatbed scanner is apparently dead. That’s actually not so bad, I should have replaced that with a regular power supply anyway and then just cut the wire and attached the original power connector on the scanner side. The reverse converter probably ate 30 W just by itself all the time.

Share
Posted in Ramblings | 2 Comments

Print This Post Print This Post  

Camera-Ready Version of PLDI Paper Submitted

This afternoon, I submitted the final camera-ready version of our Mint paper that was accepted to PLDI 2010, Mint: Java Multi-stage Programming Using Weak Separability.

Eddy and I incorporated some more suggestions we had received from Julia Lawall and Sam Kamin, who sacrificed their valuable pre-OOPSLA submission time to proof-read our paper again. Thank you so much!

I’m glad that I could sign the copyright release form by myself, and that I didn’t need to get the signatures of my five co-authors. That could have been a big headache: Walid is here, but I didn’t see him today; Eddy and Jun are in Oxford; Yilong is an undergrad at Rice, and I haven’t seen him in months; and Tamer is in Egypt. I enjoy signing other people’s rights away.

All of that is done now. I think the paper got better still, and we even managed to stay six lines under the limit of twelve pages!

Camera-ready version: Mint: Java Multi-stage Programming Using Weak Separability (PDF)

(Re-posted from The Java Mint Blog.)

Share
Posted in Mint | Leave a comment

Print This Post Print This Post  

DrJava Review: Una forma muy fácil de aprender a programar en Java

I found a review of DrJava today. It is in Spanish, and I believe the author liked DrJava:

DrJava, una forma muy fácil de aprender a programar en Java (Google translation to English)

Share
Posted in DrJava | Leave a comment

Print This Post Print This Post  

Packed Ten Days

Tonight, a very packed ten days ended. It was fun, but I’m looking forward to sleeping in.

March 10: Flight to Milwaukee, SIGCSE 2010 conference
March 12: Conference talk at SIGCSE 2010 conference
March 13: Flight to Indianapolis
March 15: Talk at Purdue University
March 16: Flight to Houston
March 18: Houston Symphony
March 19: Houston Ballet
March 20: Beer Bike, Houston Symphony

Now I don’t have any more concerts or theater performances for four weeks, and no more traveling for six weeks.

Share
Posted in Uncategorized | Leave a comment

Print This Post Print This Post  

Back and Wanting More

This is my second day back from my talks at SIGCSE and Purdue, and I’m already wanting more. We’re finalizing our Mint paper for PLDI, and I’m thinking about a nifty assignment for the SPLASH/OOPSLA Educators’ Symposium.

I couldn’t really find a lot of information about the Educators’ Symposium on the SPLASH/OOPSLA website, except that Educators’ Symposium submissions are supposedly due next week, on March 25.

Fortunately, symposium chair Ed Gehringer told me the Call for Participation will be released within the next two weeks, and that there will be 2.5 to 3 months after that to the submission deadline. Maybe it will coincide with the June 24 deadline for SPLASH posters, demonstrations, submissions to the Doctoral Symposium, Onward! films, and Student Volunteers.

Share
Posted in Concurrent Unit Testing, Teaching | Leave a comment

Print This Post Print This Post  

Happy About Purdue Talk

I’m really quite happy about the Mint talk I just gave at Purdue University. As a recurrent theme, I could have used a bit more practice, but it went a lot smoother than I would have expected, after just having presented at SIGCSE.

The best part were really the questions and comments I got. There were questions about reducing code duplication, whether we mostly see a kind of fold behavior for staged programs (this occurs in accumulators, but we can do much more), and much more.

Luke also had three crucial pieces of advice:

  1. The introductory slide comparing a general power function to a specialized power17 function and giving performance figures like 41 ns and 9 ns was weak. This ends up defining MSP and our work, and if we lose the audience’s interest here, we probably won’t get it back. We really need to open with a bang. A short opening statement about what MSP is would have been good too.
  2. At PLDI, we need to have a short explanation of how we benchmarked, and using what JVMs. I was able to answer this in the Q&A period, but it should briefly preface the benchmark table.
  3. An animation of scope extrusion showing the objects, from a memory/stack/heap point of view, could be useful in helping explain code extrusion, and it would break up the text monotony.

Thanks for the opportunity, Purdue CS, and thanks for organizing this for me, Jan and Luke.

Share
Posted in Mint, Pictures | 1 Comment

Print This Post Print This Post  

Presentation: Purdue University Computer Science Colloquia-Mint: A Multi-stage Extension of Java

Purdue University
Computer Science Colloquia
Mint: A Multi-stage Extension of Java
(PowerPoint, PDF, view embedded)
Mr. Mathias Ricken
Rice University
LWSN 3102 A/B
Monday, March 15, 2010
3:30 p.m. – 4:30 p.m.

Complete Description:
Abstract:
Multi-stage programming (MSP) provides a safe way of generating code at run-time. In mostly-functional languages like MetaOCaml, this has been used to reduce the performance penalties of abstractions such as loops, recursion or interpretation. The main advantage of MSP compared to other techniques, such as string or LISP quotations, is that MSP guarantees type safety for the generated code statically, at the time the program is compiled.

Unfortunately, MSP is difficult to combine with imperative features found in most mainstream languages like Java. The central problem is “scope extrusion”, which may accidentally move variables outside the scopes in which they are bound, leading to run-time errors in the generated code. This problem can be prevented if code in escapes (or “anti-quotes”) is “weakly separable”, i.e. the computational effects occurring inside an escape that are visible from the outside do not involve code.

We have formalized a type system, based on Lightweight Java, that uses weak separability to prevent scope extrusion, and we have proved that the type system is sound. We have also developed an implementation called Mint to demonstrate the expressivity of the type system and the performance benefits MSP can provide in an imperative setting. Since our implementation extends the Java language, our work is accessible to mainstream programmers.

This talk is based on work will be presented at the Conference on Programming Language Design and Implementation (PLDI 2010). More information is available at http://mint.concutest.org/

Bio:
Mathias Ricken is a doctoral candidate in the Programming Languages Team at Rice University and one of the principal developers of the DrJava integrated development environment. His research interests include concurrent programming, extending the Java language, and computer science education. He is the developer of the Concutest concurrent unit testing framework and has created various experimental extensions of Java to address, for instance, programming with meta-data. Currently, Mathias is contributing to Mint, a multi-stage
extension of Java that allows safe and expressive statically typed program generation and specialization in an imperative language setting.

Faculty and students wishing to speak privately with Mr. Ricken should contact Jan Vitek at jv@cs.purdue.edu.

Share
Posted in Publications | 1 Comment

Print This Post Print This Post  

Done with SIGCSE Talk

Corky and I had our presentation today, and it went well. I wish I had had some more time to practice, but that just wasn’t possible, since we decided to add something to it just yesterday. We got some good responses, though, and had a couple of controversial discussions afterwards.

SIGCSE has been fun so far. I’ve met some cool new people and said hi to some great folks that I’d met at SIGCSE conferences in the past. It’s wonderful to be somewhere where even I know someone (and someone knows me).

Share
Posted in Uncategorized | 2 Comments

Print This Post Print This Post  

Presentation: Test-First Java Concurrency for the Classroom

Test-First Java Concurrency for the Classroom
(PowerPoint, view embedded)

Where: 41st Technical Symposium on Computer Science Education (SIGCSE 2010)
When: March 2, 2010

Concurrent programming is becoming more important due to the growing dominance of multi-core processors and the prevalence of graphical user interfaces (GUIs). To prepare students for the concurrent future, instructors have begun to address concurrency earlier in their curricula. Unfortunately, test-driven development, which enables students and practitioners to quickly develop reliable single-threaded programs, is not as effective in the domain of concurrent programming. This paper describes how ConcJUnit can simplify the task of writing unit tests for multi-threaded programs, and provides examples that can be used to introduce students to concurrent programming.

Share
Posted in Publications | 1 Comment

Print This Post Print This Post  

Mint Talk at Purdue

I’m visiting my friend Luke at Purdue after SIGCSE, and we arranged for me to give a talk to the CS department.

If you have the chance, come grill me on Monday, March 15, 2010 at 3:30 PM.

Computer Science Colloquia
Mint: A Multi-stage Extension of Java
Mr. Mathias Ricken
Rice University
LWSN 3102 A/B
Monday, March 15, 2010
3:30 p.m. – 4:30 p.m.

Complete Description:
Abstract:
Multi-stage programming (MSP) provides a safe way of generating code at run-time. In mostly-functional languages like MetaOCaml, this has been used to reduce the performance penalties of abstractions such as loops, recursion or interpretation. The main advantage of MSP compared to other techniques, such as string or LISP quotations, is that MSP guarantees type safety for the generated code statically, at the time the program is compiled.

Unfortunately, MSP is difficult to combine with imperative features found in most mainstream languages like Java. The central problem is “scope extrusion”, which may accidentally move variables outside the scopes in which they are bound, leading to run-time errors in the generated code. This problem can be prevented if code in escapes (or “anti-quotes”) is “weakly separable”, i.e. the computational effects occurring inside an escape that are visible from the outside do not involve code.

We have formalized a type system, based on Lightweight Java, that uses weak separability to prevent scope extrusion, and we have proved that the type system is sound. We have also developed an implementation called Mint to demonstrate the expressivity of the type system and the performance benefits MSP can provide in an imperative setting. Since our implementation extends the Java language, our work is accessible to mainstream programmers.

This talk is based on work will be presented at the Conference on Programming Language Design and Implementation (PLDI 2010). More information is available at http://mint.concutest.org/

Bio:
Mathias Ricken is a doctoral candidate in the Programming Languages Team at Rice University and one of the principal developers of the DrJava integrated development environment. His research interests include concurrent programming, extending the Java language, and computer science education. He is the developer of the Concutest concurrent unit testing framework and has created various experimental extensions of Java to address, for instance, programming with meta-data. Currently, Mathias is contributing to Mint, a multi-stage
extension of Java that allows safe and expressive statically typed program generation and specialization in an imperative language setting.

Faculty and students wishing to speak privately with Mr. Ricken should contact Jan Vitek at jv@cs.purdue.edu.

I’m a bit relieved that the sentence “He also has a weakness for Lady Gaga videos.” was left out of the bio.

Share
Posted in Mint | Leave a comment

Print This Post Print This Post  

10.4 Programs, A Dying Breed

MacOS 10.4-compatible programs really are a dying breed. First, VLC stopped supporting 10.4 in new versions (last 10.4-compatible version is release 0.9.10), then Eclipse stopped supporting 10.4, and now VirtualBox has dropped support for 10.4 as well (last 10.4-compatible version is 3.0.12). I guess it’s high time for a new MacBook (Pro), but I want to wait for the next update.

You may ask why I don’t just install MacOS 10.5 or 10.6. As I explained before, because Apple doesn’t support Java 6 on 32-bit Macs. I have a first-generation Intel MacBook (Core Duo, not Core 2 Duo), and I need Java 6.

Share
Posted in Ramblings | Leave a comment

Print This Post Print This Post  

Review: DrJava – A Simple IDE For Beginners

I found a nice review of DrJava today, written by Julian Jaic.

DrJava is a simple and light IDE for Java development. It is a free, open source IDE primarily designed for students. But it also includes powerful features for more advanced users. It has integrated debuggers, support unit testing with Junit and tools to generate javadocs. DrJava is available for multiple platforms, including Windows, Linux, and Macintosh.

DrJava is an ongoing project at Rice University, Texas, developed and maintain by students. DrJava shares the goal of providing a preparatory training environment that decreases the fear factor experienced by beginning students. This project provides an interface that is simple, interactive, and with a focus on the language.

REPL – Read Eval Print Loop

The eminent feature of DrJava is the ‘interactions pane,’ a ‘read-eval-print loop’ (REPL) for evaluating Java expressions and statements interactively. Functional languages such as ‘Scheme’ have long used Read Eval Print Loop. That make easy program development. Users experiment with Java constructs by typing an expression or statement will compile immediately without having a complete java code. REPL makes it possible to completely avoid the difficulties of Java I/O at the introductory level by using parameters and function return values. The interface is text based, and does require using Java syntax. This design was deliberately chosen so that only a single medium is required for dealing with program development, in contrast to the combination of UML and Java source code. Interactions can easily process graphic objects.

User Interface

DrJava keep up a focus on Java and it gives two components, a definitions pane and an interactions pane in a ‘single window environment’. In definitions pane, when a class is compiled, it is directly available in the interactions pane for another uses. The Read Eval Print Loop features of the interactions pane boost understandable functional programming in association with the object-oriented model. The interactions pane keeps a history for comfortably recollecting the already inserted commands. This decreases the typing needed when going for experiential evaluations.

A Lift Current Interaction to Definitions command copies an interaction into the editor. This gives a comfortable way to move experiential tests into a JUnit test to make them repeatable. Since each class method can be executed independently, the interactions pane is an impressive tool for small testing and troubleshooting. It also contains a debugger that helps adding breakpoints and explaining watches. In debug mode when execution is break up at a breakpoint, the interactions pane can be used to check or modify state variables using Java statements and expressions. Again the design approach was to maintain an easy and steady interface throughout. It’s compiler shows all syntax errors by parsing the file. Clicking an error message highlights the error in the source code.

Dr.Java’s editor supplies automatic braces /parenthesis matching, comment /quotation highlighting and indentation that is refreshed in every keypress. A complete Java class can properly formated by an ‘Indent lines’ command. The editor supports several documents but does not arrange files into projects. To organize files, it is necessary to use the operating system’s file management facilities. Another features of DrJava contain built-in support for JUnit test cases creation of javadoc and it’s preview.

DrJava’s developers suggest that the IDE is useful beyond the beginner level, and cite advanced courses at Rice University that feature projects for extending the tool. One such project produced a DrJava plugin available for the Eclipse IDE that should ease the transition to the more powerful features of a professional IDE.

IDE’s are very important tools for easing the entry of students into software development courses. Dr.Java serve easy interfaces especially designed for teaching. It encourage cumulative development and associative experimentation, which will possibly the most important feature of this IDE. DrJava provide excellent options for simple entry level software development in Java. DrJava has a cleaner and easier interface that manages a focus on the Java language.

Julian is a professional content writer on software development and now working at Telious Technologies.

Article Source: http://EzineArticles.com/?expert=Julian_Jaic

Thanks, Julian! Actually, DrJava does have a project facility.

Share
Posted in DrJava | Leave a comment

Print This Post Print This Post