Pages

Thursday, December 27, 2007

An Interesting Reference to Google.com

Yesterday my mother made me a Christmas gift - a book. This book is called "Stress as an Asymmetric State. Natural Healing". Nice hardcover, approximately 125 pages. But on the very first page, where all the copyrights are listed I found something very strange to my mind.

I found the following. At the line 4 of the copyright page there's a reference to www.google.com. It says:
All the illustrative material comes from www.google.com and is adopted for this book


Pardon me, but I doubt that any trustworthy author would refer to a search engine in his/her text. Say, if you make a student project at university, will you refer to {yahoo|altavista|google|yandex}.com to make your text look authoritative??? I don't think so. I can think that the authors did not even know about this reference, but the respectful publisher should have thought twice before passing this one to production.

Tuesday, December 25, 2007

Hibernate Books Review

Java Persistence with Hibernate


Java Persistence with Hibernate was a good reference to me, but the book tries to be everything for everybody and this is what makes it a little hard to read. The book covers all the aspects of Hibernate framework in detail, starting from the ORM fundamentals up to conversational processing which is not found in any other Hibernate-related books.


Hibernate Quickly


As the name says, Hibernate Quickly is best suited as the introductory reference to Hibernate. The books follows the problem-solution pattern: at the beginning of each chapter, a bullet list of the topics is followed by the goals which a targeted by this chapter. This is what makes the book well-structured and easy to follow. I found a lot of easy to understand examples accompanied with good text explanations in this book and I think it is the best way to lean something new - by examples.

Wednesday, December 12, 2007

VARCHAR constants, Oracle 10g, and Oracle JDBC driver

Every day I have the luck to write some JDBC code @ work, and sometimes, in very specific conditions I face very strange errors. This post is about one problem that encountered while running a Java application, that queried a view in Oracle 10g database using Oracle JDBC driver v9.

In order to work with a complex database schema, a view was created to be used as an interface for a simple JDBC application. According to some specific business requirements, the view has to contain character constants - say, "if a column value is NULL then a query to the view should return 'X', otherwise, return the column's value". For this purpose, the view was created using the CASE/WHEN statements:

CREATE OR REPLACE VIEW view_name AS SELECT
CASE
WHEN column_name='X' THEN 'A'
ELSE 'B'
END
FROM DUAL

So, running a query "SELECT * FROM SOME_VIEW" was working OK and once we deployed the application in production we started to get some strange values from database. Instead of getting 'X' as it was defined, some whitespaces where added to the values, so that 'X' became 'X ', with two extra whitespaces, i.e. length 3 instead of length 1.

After some research we discovered that the system administrator was using Oracle JDBC driver v9 instead of a new one. Probably there are some "religious" reasons, why the version 9 should be preferred over version 10 for Oracle JDBC driver, especially with Oracle database version 10g. But the strange behavior of the application and the extra whitespaces problem had to be resolved to make the application work with the older driver.

Trimming every value that would be received from the view sounds like a stupid idea. So the first step was now to find out why the view constant was equipped with extra whitespaces. AFIAK, in Oralce 8i JDBC applications it was the common case that a CHAR type values were fetched with the whitespaces untrimmed, thus the obvious decision was made to seek for the view column type definition.

The metadata for a column's type is written in USER_TAB_COLUMNS and USER_COL_COMMENTS .

SELECT *
FROM user_tab_columns ut
, user_col_comments uc
WHERE ut.table_name = ? -- name of the created view
AND ut.table_name = uc.table_name
AND ut.column_name = uc.column_name
ORDER BY ut.column_id

So the column type was CHAR(3)! So the error could be fixed if the view could be created in such way that the problematic column could be VARCHAR2. A CASE/WHEN statement can be replaced with DECODE function, thus:

CREATE OR REPLACE VIEW view_name AS SELECT
DECODE(column_name, 'X', 'A', 'B')
FROM DUAL

The column type in the metadata table is now VARCHAR2(1)!

The strange thing is now actually why the driver version 10 was working correctly with the CHAR type. Correctly in sense of trimming the witespaces, but is it really correct behavior? (a rethorical question)

One special case was solved, but in some other views some constants were defined without any conditions:

CREATE VIEW some_view AS
SELECT
.....
'X'
.....
FROM table_name
WHERE condition

The value was still defined as CHAR in the metadata table. I don't know why, but I decided to describe the constant using TO_CHAR function with a random parameter, like this: TO_CHAR('X', 1). Apparently, it worked (!). The column was defined as VARCHAR2 now, but with maximum length of 4000. Is this some sort of undocumented feature of TO_CHAR function?! So far I knew that TO_CHAR function can be applied to a NUMBER or DATE type argument...

CREATE OR REPLACE VIEW view_name
AS SELECT TO_CHAR('A',1) FROM DUAL

The type issue was solved but in fact reserving 4000 symbols for the one-character-long constant is somewhat an overkill. Defining the constant via DECODE function solves this problem as well: DECODE('X', 'X', 'X'). So the type was now VARCHAR2(1).

CREATE OR REPLACE VIEW view_name
AS SELECT DECODE('A','A','A') FROM DUAL

After changing the views definitions the application started to work correctly with Oracle JDBC driver version 9.

The Morale
There's several things I have learnt with this issue:
1) always verify the view definition metadata in Oracle.
2) Oracle JDBC drivers are broken and behave oddly.
3) Oracle TO_CHAR function has some undocumented behavior.

Tuesday, November 20, 2007

Google Android and IntelliJ IDEA

Just some days after Google Android was released, IntelliJ has already support it! IDEA Android plug-in provides a special facet along with other nice features like autocompletition, packaging, etc. I think I should give Android a try.. just for fun, and to see how much better it is compared to the classical J2ME coding.
Although the Android Developer Challenge seems quite motivating, I feel I have no such skills to come up with something really meaningful to be competitive.

NORCHIP2007 Logo

One funny thing we've noticed about NORCHIP2007 is the logo. The logo depicts the map of the countries where the conference has taken place. The strange thing is that Riga and Tallinn are missing as such, however both the cities belong to the organizers community.

NORCHIP2008 will be held in Tallinn and it seems that the organizers will have to add the baltic states to the logo.

The Empty Streets of Aalborg

The last Sunday I was walking around the city of Aalborg. I was shocked how empty it was. Just noone on the streets and I met just a few people walking. This is something unimaginable compared to Tallinn... It must be very boring to live in such city where you can meet noone and all the shops are closed all the weekend.




This explains why NORCHIP2007 conference is being held here: the attendees just have nothing else to do and are forced to attend the lectures! :)

Wednesday, October 24, 2007

Book Review: Design Recipes for FPGAs

Design Recipes for FPGAs is a sort of "something about everything" book. The book just lists the FPGA-related issues and doesn't cover any of those in detail. Even if there are some kind of examples - I wouldn't recommend this book to anyone. Istead, The Design Warrior's Guide to FPGAs is a much better alternative.

Book Review: The Design Warrior's Guide to FPGAs

The Design Warrior's Guide to FPGAs is a must-read book! Written in an entertaining style, the books is very interesting to read. The book provides an insightful overview of the FPGA technology, design tools and flows. This is a great book for someone that is getting started in FPGAs. After reading this book one will have the basic knowledge about FPGA technology.

Monday, October 22, 2007

Book Review: Mastering Enterprise JavaBeans 3.0


Another book about EJB 3.0 is Mastering Enterprise JavaBeans 3.0. The book focuses on the changes made since EJB 2.1. Here are some week aspects of this book:

  • it is not that smoothly readable as the previous EJB book

  • the book spends too much on high-level introduction of EJB 3.0 specification while it could dive into more practical details ASAP

  • JPA is poorly covered


But nevertheless, the book is somewhat a good complementary material for learning EJB 3.0.

Sunday, October 14, 2007

Book Review: EJB 3 in Action

EJB 3 in Action was really enjoyable to read. This is a well-structured book and covers just what is really required for Java 5 EE application development. In my opinion it is not the best suited for a beginner: it is easier to understand the text if one already has some experience with EJB 2.0. The book provides practical code examples, best practices, design patterns, and performance tuning tips.
I would strongly recommend this book to anyone who would like to get familiar with EJB 3.0.

P.S. The relevance to the JEE development is out of the scope here :) Personally, I would rather go Spring/Hibernate than JSR220 and JSR291 rather than JSR277.

P.S.2 Why not to assume that Hibernate and Spring are the de jure standards for JEE middleware development, instead of creating EJB 3.0? Political reasons? I think that Sun is still reinventing the wheel with its own "standards" and not making use of the community process.

Wednesday, September 12, 2007

My Ubuntu

After years being a windows user, eventually I decided to join Linux community. The main reason is that this platform is more attractive from the open-source software point of view. After reading some forums and newsgroups I decided to try Ubuntu for my Fujitsu-Siemens laptop. Although I have a 64 bit system I have chosen not to ask for problems and picked the 32-bit distro.


The only thing that was keeping me from moving to Linux is M$ Excel, which is used is our university at the informatics lessons for VBA programming, and the last 5 years I had some friends asking for help with that. Now I think I have had enough of that and next time I would be asked for VBA help I'll say I know nothing about it :)

The first impression from using Ubuntu is very positive! Installation of the system was so rapid that I even thought that there's an error and something didn't work :) Very cool! First I tried to install only the KDE version but eclipse refused to work with that one. With Gnome everything is working, here's the check list:

- eclipse (ok)
- firefox, with flash player (ok)
- USB memory stick (ok)
- SD card reader (ok)
- external USB hard-drive (ok)
- playing wmv/avi/mpeg/flv (ok)
- playing mp3 (ok)
- burning CD/DVD (ok)
- viewing graphics/pdf/chm/djvu (ok)
- Skype/Gtalk/Yahoo!Messenger/MSN/ICQ (ok)
- Xilinx WebPACK/ModelSim - (haven't tried yet)

I haven't tried to connect a webcam so far. And one thing I have problem with is running Picasa on wine - it just hangs at the splash screen and does nothing.

Now I've got to find a file manager a-la Windows Commander, coz I'm not impressed with Nautilus file manager.

I have to say that I'm not a Windows-hater. I think that most of the "linuxoids" words that "Windows must die" or "Windows is a crap", are meaningless. I had no problems using Windows besides keeping the anti-virus database up to date, which is not that hard. It is just the nature of my hobby (read oss programming) that requires something else than a proprietary Windows system.

Tuesday, July 31, 2007

A Case for Groovy Singleton

In my last post I've written about the new feature in Groovy API, the GroovySystem class. Now I would like to give it a try for the singleton pattern implementation inside the plug-in extension.

Why would I ever want to do that? The singleton class could be used for persisting the state between the same action calls. I wanted to try this solution just because it must be possible to implement the same thing in the different ways. Nothing else.

Here's an example:

def expando = new groovy.util.Expando()

class MySingleton {
String toString() { 'MySingleton: ' + hashCode()}
}

class MySingletonMetaClass extends MetaClassImpl {
private final static INSTANCE = new MySingleton()
MySingletonMetaClass() { super(MySingleton) }
def invokeConstructor(Object[] arguments) { return INSTANCE }
}

def registry = GroovySystem.metaClassRegistry
registry.setMetaClass(MySingleton, new MySingletonMetaClass())

expando.run = {action ->
expando.workbenchWindow.getActivePage().
showView("org.eclipse.soc.yummy.views.ScriptView")
println "hello groovy action: ${action}"
def single = new MySingleton()
println "${single}"
}

I just create a singleton using the GroovySystem and MetaClassImpl, so that when an action delegate gets called, I will have always the same instance of the singleton class.

Unfortunately, I didn't find a way to implement the same in case of different scripts, e.g. if I have two different scripting extensions. Perhaps I will have to provide a single class to the plug-in which could be used just for this purpose.

Monday, July 30, 2007

JSR 223 and Groovy 1.1 Beta 2

In Groovy version 1.1-beta-2 a new class groovy.lang.GroovySystem provides some nice features that I would like to use in my Google Summer of Code project. Namely, this is one way to implement a bundle activator for an eclipse plug-in. Not really an activator, actually, but sort of.

In a scripted bundle, the activator can be just a singleton class, and GroovySystem can be used to create a fancy singleton pattern in Groovy, like it is described at Groovy's homepage.

The problem I faced when I tried to initialize the scripting engine using javax.sript API, was that the engine implementation still thinks that groovy.lang.MetaClass is a class, but it is an interface in the latest version of Groovy.

So the stack trace of this exception was:

Exception in thread "main"
java.lang.IncompatibleClassChangeError:
at com.sun.script.groovy.GroovyScriptEngine
.(GroovyScriptEngine.java:63)
at com.sun.script.groovy.GroovyScriptEngineFactory
.getScriptEngine(GroovyScriptEngineFactory.java:87)
at javax.script.ScriptEngineManager
.getEngineByName(ScriptEngineManager.java:225)

The quickest fix I could do, is to download the scripting engine sources from the website, and comment out the line in GroovyScriptEngine's static initializer. After the recompilation I didn't get the stack trace any more, but I think I have to investigate a bit more, what could be affected by this change.

Thursday, July 19, 2007

The ViewPart Should Be Equal

I was preparing an example of a groovy view extension for my GSoC project tonight. First, I created a groovy class that extends org.eclipse.ui.part.ViewPart and added the required methods to that class:

class MyView extends ViewPart {
public void createPartControl(Composite composite) {
}
public void setFocus(){
}
}

def view = new MyView();
view

The first disappointment was that I couldn't write the method declarations in a groovy way, using def, because it was yelling that the abstract methods should be implemented. Thus I conclude that I cannot implement the abstract methods using def.

So far, so good... OK, when I executed the above script I got a nice stack trace, saying that "A part must be equal to itself", and/or "A part must have a meaningful equals method". This was a message from org.eclipse.ui.internal.PartTester#testWorkbenchPart(), that checks the brand new part for some strange things, like part.equals(new Integer(32)). Why 32, can anyone tell!?

So I implemented a goofy equals() for my script object, just to make it work. Here's the example code: view.groovy.

Wednesday, July 18, 2007

GSoC 2007: Equator Reached!

The midterm evaluation is complete and just over a month is left to do the project, and the deadline is approaching fast.

The last post about the facade implementation for each extension was just a concept showing what could be done for mapping the extension method calls to the script. But implementing a dedicated facade for each extension is not feasible just because there is an unlimited number of the extension types available.

As the previous post said, a proxy class solution could solve the problem so that I shouldn't write a dedicated facade for each extension. That said, we have a brand new solution in place: the ScriptExtensionProxy class, which implements the following interfaces:

  1. IExecutableExtension required for extension initial setup in ConfigurationElement#createExecutableExtension() calling IExecutableExtension#setInitializationData()

  2. IExecutableExtensionFactory required for proxy class construction using IExecutableExtensionFactory#create() call in ConfigurationElement#createExecutableExtension()

  3. InvocationHandler required to delegate the extension method calls to the script in InvocationHandler#invoke() method.

The example script still works the same way as previously, but no facade class required any more.

The declaration of an extension is changed a little bit, as I have to define a proxy class, an extension interface class and a script file in the class attribute in plugin.xml:

<action class="org.eclipse.soc.yummy.core.ScriptExtensionProxy: \
org.eclipse.ui.IWorkbenchWindowActionDelegate/action.groovy"
icon="icons/sample.gif"
id="ScriptAction"
label="&Sample Action"
menubarPath="sampleMenu/sampleGroup"
toolbarPath="sampleGroup"
tooltip="Hello, Eclipse world">
</action>
It looks a little messy though...

Overall, providing the scripting support for developing plug-ins in Groovy requires only three classes at the moment: a proxy, a script execution engine, and a helper class for initialization code that is actually used in the proxy class only. LOC = 355.


Next, I will have to make many examples to see what is missing in ScriptExecutor and to find out which workbench objects should I expose to the script. I still need to refer to Dash for this purpose.

Sunday, July 8, 2007

Eclipse plug-ins and JSR-223

Recently I was trying to bind the eclipse plug-in world with JSR-223 and Groovy via javax.script API for my GSoC project. Here's how it turned out.

First I need to have a class that deals with all that javax.script stuff: let there be ScriptingExecutor. Its functionality isn't very advanced - it just delegates the calls to the scripting API and maintains several fields for holding the state of the script. STOP! Why would I need to keep track of the state at all? The problem is that not all the scripting languages with the same semantics/features.

Let's see the example: an action facade and a script that implements this action. I'm using the Expando object to create a class with the same methods as for the action: run(IAction action), selectionChanged(IAction action, ISelection selection), dispose(). The reason why i would like to pass the new object back to the plug-in is that when a selection is changes I would like to save the reference for further processing in the run(IAction) method. The script below has a visibility problem and cannot use def selection to save the state.

def selection

def run(action){
println "selection = ${selection}" // this won't work!!!
}

def selection(action, selection){
this.selection = selection
}

The Groovy User Manual says:
Executing this code you get an exception talking about a missing property or field.
The only things the method has access to are:
* the binding,
* attributes defined by the base class, and
* the dynamic properties defined by the MetaClass (explanations for these will follow).
So I decided to use Expando as a base class for saving the state. Simple.

Next, there are 2 options of delegating the plug-in extension to the script object:

  1. Using the invokeMethod/invokeFunction methods of the javax.script.Invocable interfaces. These can be used just for simply calling the functions from the evaluated script. or...

  2. Using getInterface(Class clazz) to create an object that would implement the required interface, of instance IActionDelegate.

I'm not sure which option is really better so I'm using the first one for now.

Next, I should try to implement several facades and scripts for the extensions, so that I could see the common parts and unify them in one. Implementing a facade for every single extension does not seem to be very relevant, perhaps the getInterface(Class clazz) method will help to skip that... Or I will need some sort of Proxy solution to skip all the facades.

Also I'm referencing Eclipse Monkey project as an inspiration. The reason is that for smoothing the script development a set of predefined variables could be very handy, so the user could use them out of the box. And that is what Eclipse Monkey does: it exposes some internal object into the script context so that a script contributor could use them.

Wednesday, July 4, 2007

The Summer of Code goes on

I feel the guilt because of not posing about the GSoC event so far. Perhaps should start blogging more about what I am doing at all.

For the project I have 3 goals now, sorted by priority:

1. Provide the ability to write the plug-ins in a scripting language.
Basically it means that a new plug-in could be implemented in any scripting language, supported by JSR-223. My mentor, Wayne, purposed a tricky solution to bind a script to a popup action using a syntax feature for the action definition in plugin.xml:
<action
class="scriptexecutor.actions.ExecuteScriptAction:my.script"
icon="icons/sample.gif"
id="scriptexecutor.actions.SampleAction"
label="&Sample Action"
menubarPath="sampleMenu/sampleGroup"
toolbarPath="sampleGroup"
tooltip="Hello, Eclipse world"/>

An action class ExecuteScriptAction will be provided by the supporting plug-in, and my.script is something that is implemented by the new plug-in developer.
ExecuteScriptAction will act as a facade to the scripting world, setting the required variables to the script context and running the script itself, using javax.scripting API.
public class ExecuteScriptAction 
implements IWorkbenchWindowActionDelegate,
IExecutableExtension {

private URL script;

...

@Override
public void setInitializationData(IConfigurationElement config,
String propertyName, Object data)
throws CoreException {
Bundle bundle=Platform.getBundle(config.
getContributor().getName());
Enumeration entries = bundle.findEntries("/",
data.toString(), true);
if (entries == null) return; // The script wasn't found.
URL entry = null;
if (entries.hasMoreElements()) entry =
(URL)entries.nextElement();
this.script = entry;
}

...
}

So basically, setInitializationData() sets the parameter to the action class and after that we can do whatever we would like to with the script file when IActionDelegate#run() is called for this class. Most probably I will have to pass a pointer to the current workbench to the script context, like Eclipse Monkey does.

2. Enable custom processing for plugin.xml, to be able test the new plug-ins without starting the 2nd eclipse instance.
This was actually the initial idea, but it seems that enabling scripting for the bundled plug-ins is more valuable. Probably it is better to bundle this functionality as a separate plug-in even. Processing plugin.xml will involve parsing the configuration and registering the extensions to the same workbench where the brand new plug-in is being developed.
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint point = registry.getExtensionPoint
(EXTENSION_POINT_ID);
IExtension[] extensions = point.getExtensions();

for (IExtension element : extensions) {
// register the extension
}

3. The console, for providing the interactive (re)loading of the plug-in. I'm not very sure yet, will it be a Apache Derby ij style console, or will it be a set of controls, but definitely it is a good feature to implement to smooth plug-in prototyping.

Now, after a good vocation in Croatia, will have to speed up things a bit to be in time with the implementation.

Tuesday, June 26, 2007

Eclipse Europa is coming!

An annual release of Eclipse is coming soon! The release includes 21 projects.
The Next Total Eclipse
Eclipse is the leading platform for tools I think, but sometimes it seems too heavyweight to me. Lately I tried to download all the Eclipse projects and while running the Eclipse instance I was getting OutOfMemoryError all the time. It seems that for every programming purpose I should have a separate Eclipse instance to avoid the memory problems: one instance for JEE development, one - for BIRT reporting, one - with CDT installed. In other words keep the configuration of current instance minimal.
Here's another interesting blog entry about Eclipse platform at Application Platform Strategies Blog

Monday, June 25, 2007

Hols in Croatia

Spending holidays in Croatia: 19.06 - 03.07.

The plan: Dubrovnik - Peljasac - Makarska - Split - National Park Krka - Zadar - Plitvice Lakes - Trogir - Brela Beach - Cavtat

To find accommodation: http://www.apartmani-hrvatska.com



Dubrovnik - a city on the Adriatic Sea coast in the very south of Croatia, a seaport and the center of the Dubrovnik-Neretva county. The old city of Dubrovnik is listed at UNESCO World Heritage Site.

Peljasac - a peninsula located ~60 kilometers north to Dubrovnik. Nice coastline, wine yards, and neat camps can be found here.

Makarska - a small town on the Adriatic coastline of Croatia, about 60 km southeast of Split and 140 km northwest of Dubrovnik. Makarska is center of Makarska rivera, both touristic and cultural. It is possible to find accommodation in Makarska itself as well as in the neighboring places.

Split - the largest and most important city in Dalmatia. The beginnings of Split are usually linked to the building of Diocletian's Palace, which is a place to see. Split is the only city where we found a sandy beach, coz all the rest coastline is mostly of rocks ans stones.

National Park Krka. Krka is a river in Croatia's Dalmatia region, with length circa 73 km; famous for its numerous waterfalls. This is a nice place worth visiting, but before Plitvice Lakes!!!

Zadar, the fifth largest Croatian city. A city with a rich heritage of world importance, visible at every step. The Roman Forum from the 1st century, St. Donatus’ Church from the 9th century is the most famous medieval basilica and trademark of the city. Also, a unique sea organ was built in Zadar in 2005.

Plitvice Lakes. This is a must-visit-place! Many small lakes, separated by natural dams produce an astonishing view. The park is also added to UNESCO's List of World Heritage and this is the major tourists attraction in Croatia.

Trogir - historic town, next to Split, which has 2300 years of continuous urban tradition. The city is inscribed in the UNESCO World Heritage List. Trogir has a high concentration of palaces, churches, and towers, as well as a fortress on a small island. This is the best-preserved Romanesque-Gothic complex not only in the Adriatic, but in all of Central Europe.

Brela Beach. Brela is a village in the Split-Dalmatia county of Croatia, a part of Makarska Rivera. The Brela beach is so perfect, it's hard to believe you're still in Europe. It's one of Croatia's best resorts with crystalline water and pebble beaches.

Cavtat is the most southern city in Croatia. The Cavtat area is most attractive because of the Mediterranean vegetation which covers the whole area. Numerous bars and restaurants line the waterfront, offering everything from cheap pizza to more expensive local specialties: the Cavtat is a good as any, with a repertoire from simple pasta dishes to succulent fresh fish.

Croatia is a beautiful country and a perfect place for those looking for crystal clear water and plenty of sunshine.

Wednesday, May 16, 2007

The Road from JavaOne - Southern California

Santa Cruz, a must see place at the west coast, was the first destination on the Pacific Highway for us. The beach in Santa Cruz is the right place to have a rest.The views of the Pacific Highway are amazing!
And finally...... the Universal Studios scenery on the War of the Worlds movie...

The Road from JavaOne - Nothern California

Good bye San Francisco, I'll be back! :)The next stop was in Yosemite.Great views, I have to say!The next morning we visited the ghost city - Boddie.And the same day evening we were in Lassen Volcanic......and had a pleasure to enjoy the views! :)After this we held a rally back to the south - to Santa Cruz.

to be continued...

Wednesday, May 9, 2007

JavaOne - Day 4

I have listened the general session (supervised by James Gosling) about various innovative robotic-oriented products, like helicopters, submarines, industrial robots etc. One special - the WowWee robosapien V2 - was presented as well. Now I have one too! :)
The session called Bytecode Manipulation Techniques for Dynamic Applications for JVM was really good. First, Eugene Kuleshov described ASM quickly, and after that some of the applications were descried: TopLink, Terracota DSO, and JRuby language compiler.

Next, I attended Java Puzzlers session, brought by Joshua Bloch & William Pugh.

Finally I was at JRuby session about DSLs. I didn't really get the point here actually. What's the point of implementing a specialized language for a corporate actions calculations? We can do the same Java and support it even better, specially if we have high performance requirements, which is not applicable to JRuby at the moment.

JavaOne - Day 3

Learned how to implement OpenOffice.org extensions with Netbeans. This could be very useful if my company used OpenOffice instead of M$ Office.

Advanced Groovy. This was almost the very best technical session I've been to so far! Nice examples with interactive console, very detailed explanations - it deserves 11 by the scale of 10!

Next, I tried to write an application using Web21C SDK, and received a radio-controlled helicopter for that! :)

The other sessions I've been to:
- OpenJDK report
- Ruby tooling: debugging end autocompletition support
- Manageble systems with JMX, AOP, Spring and Groovy
- BOF session: Lessons learned in plug-in development (for Eclipse, IDEA and Netbeans)

JavaOne - Day 2

JavaOne Pavilon is a great place I think. You can meet people here and get even more information about the issues you're interested in than from technical sessions. I had a chat with James Strachan. He was promoting Camel to me:)

I also saw a demo of a Talend and I have to admit this is a great ETL product! The demo was so smooth and I will definitely give it a try after I'm back home. It is a pity that it does not support JMS yet, but since it is open source I feel like adding this feature myself if it wont be available soon.

Sybase's IDE for database looks promising - should give it a try too, I think.
Tangosol Coherence is the next technology on my list. I had a short chat about it with the Tangosol's representative and I believe it can solve some of our data integration problems in Hansabank.

I also attended Sun SPOT lab this day. The lab consisted of 7 well-prepared exercises, using 2 Sun SPOT devices and a TruckRobot by Syntronics. I wish I could by by the toolkit but unfortunately this is being sold in US only and I could not by one if I have no US address (damn!). Hopefully, it will be available in Europe soon.

The BOF session on dynamic languages was OK ( hello Charles! :) ). Actually, the comparison of the languages could be done by anyone, but the real value of this session was the discussion on the features that could/should be available in these languages.

The session called Building Web User Interfaces in the Java Programming Language with Google Web Toolkit didn't bring anything new to me, but it was interesting to listen.

This was a great day 2 at JavaOne for me. Lots of information and fruitful discussions. I wish all the rest could be the same :)

P.S. Some chocolate for developers can also be found in pavilion :)

JavaOne - Day 1

General Session. We've been presented a new hype technology from Sun - JavaFX script, which should bring the UIs to the next level. Also some frameworks were presented that should make the world yet better - JMaki & Phobos. Also Netbeans 6 was shown with the support of JRuby language editing/debugging.

I attended a session called Cool Things You Can Do with the Groovy Dynamic Language where Guillaume Alléon and Dierk König showd us the power of dynamic object manipulations with groovy language. That was really fun and a pleasure to listen and see. I'd suggested this session to anyone.

At Sun SPOT in Action: 3D, Virtual Reality, and Gaming I met the Sun SPOT device the 1st time live :) The talk was about the virtual reality gaming in general and what is required to archive the responsiveness of the game controls.

Easy Deployment Is Finally Here was a bit disappointing, as I expected a little more than just getjava.exe description.

Finally, I met my GSoC mentor, Wayne. We had a fruitful conversation on the GSoC project, so now I think I know where to start! :)

The Road to JavaOne

We landed in LA on the 3rd of May, so we had time for a small trip on the way to San Francisco. Everyone was exited about visiting Joshua Tree National Park, Las Vegas and Death Valley. Here's how it turned out.
The day after landing in LA we had a trip over the Joshua Tree National Park - seen a lot of cacti ...
... and the joshua trees.Before going to Las Vegas we've visited Hoover Dam, just for some of us to see what it is.After spending next night in Las Vegas we moved west, to Death Valley's salty basins ......and sand dunes...
And after Death Vally - we saw sequoias:, and General Sherman tree in particularWe reached San Francisco on the 7th of May, very late in the evening.

Saturday, April 21, 2007

_JAVA_LAUNCHER_DEBUG confusion

Yesterday a tried to see what happens if I set _JAVA_LAUNCHER_DEBUG environment varable. So, I have set _JAVA_LAUNCHER_DEBUG=true, and started an application...
In Cygwin, for instance:

ant@jupiter ~
$ export _JAVA_LAUNCHER_DEBUG=true

ant@jupiter ~
$ java -version
----_JAVA_LAUNCHER_DEBUG----
JRE path is c:\jdk1.5.0_11\jre
jvm.cfg[0] = ->-client<-
jvm.cfg[1] = ->-server<-
jvm.cfg[2] = ->-hotspot<-
name: -hotspot vmType: VM_ALIASED_TO alias: -client
jvm.cfg[3] = ->-classic<-
jvm.cfg[4] = ->-native<-
jvm.cfg[5] = ->-green<-
1530 micro seconds to parse jvm.cfg
Default VM: client
JVM path is c:\jdk1.5.0_11\jre\bin\client\jvm.dll
6299 micro seconds to LoadJavaVM
JavaVM args:
version 0x00010002, ignoreUnrecognized is JNI_FALSE, nOptions is 2
option[ 0] = '-Djava.class.path=.;C:\Program Files\Java\jre1.6.0\lib\ext\QTJava.zip'
option[ 1] = '-Dsun.java.launcher=SUN_STANDARD'
java version "1.5.0_11"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode)

OK, nice, it works... I have set _JAVA_LAUNCHER_DEBUG=false and continued with my work.

In a few minutes I wanted to compile some application using IntelliJ IDEA, but as the compilation process stared the IDE just hanged and did nothing. Restarting the IDE didn't help. Confused! I've reinstalled IDEA, upgraded to a new version even - nothing helped - it just hanged when I tried to compile anything.

Damn! I memorized now about the environment variable I've set. Removed that. IDEA compilation succeeded.

The moral is that JVM doesn't care which value is set to _JAVA_LAUNCHER_DEBUG: either 'true' or 'false'. It could be 'foo', 'bar' or 'John Doe' as well - JVM requires this environment variable to be set for debugging and doesn't need the value at all.

Wednesday, April 18, 2007

JSR 223: Scripting for Java

As Charles Nutter suggested, I decided to try javax.scripting API. The Java 6 Revealed book has a nice chapter on JSR 223 and also an example of Pnuts integration with JVM.
I have downloaded the other engines from java.net. It seems that for my SOC project it is reasonable to use Java 6. Virtually it will be possible to write plug-ins in any scripting language for which the engine is available. We could even use combination of many languages, just selecting the relevant engine by name or file extension:

ScriptEngineManager m = new ScriptEngineManager();
ScriptEngine groovyEngine = m.getEngineByName("groovy");
ScriptEngine jrubyEngine = m.getEngineByName("jruby");

The full list of the scripting engines is available at java.net

Monday, April 16, 2007

Google Summer of Code 2007

My application to Google Summer of Code was accepted! Now the summer will be full of fun of Groovy and JRuby plug-in implementation to Eclipse.

Why I decided to participate? Don't know. Maybe I'm starting to get bored by writing JDBC applications all the time, will see how it turns out.

Sunday, April 15, 2007

Office Space

Just realized now I'm getting short of space... No as bad as the codehoopers but it is getting dangerous. I think I need a second level table on the wall and I definitely require a new chair. Thank god I have a Wi-Fi router now and don't have to drag the Ethernet cables all around :)

Friday, March 30, 2007

MicroBlaze Development Kit

I have a new toy - MicroBlaze Development Kit from Xilinx! :)



The main feature for me here is the USB download feature as my laptop doesn't have a serial port as most of XESS boards require. Hopefully I can do all my hardware emulation research tests with this board now :)

The Key Features are:
* Device Supported: XC3S1600E FG320-4CS1
* Clocks: 50 MHz Oscillator (soldered) , 66.67MHz Oscillator (socketed)
* Memory: 512Mb (32Mx16) DDR SDRAM, 128Mb (32Mx8) Parallel Flash, 16Mb SPI Flash, & Xilinx Platform Flash
* Connectors and Interfaces: Two RS-232 Serial Ports, 1 10/100 RJ45 Ethernet Port, DB 15 VGA Display, LCD Graphic Display, SPI Port, 1 PS2 Port, 4 channel DAC and 2 channel DAC, General Purpose I/O: Buttons, Switches, LEDs, Rotary Encoder, and 43 Bit User Expansion (16 Diff-Pairs) Connector, and three 4-bit I/O Connectors and 14 Input only I/O, 50MHz and socketed 66.67 OSC, and 1 SMA input.
* Display: 16 x2 Character LCD, RGB VGA

Friday, March 2, 2007

Compiling uClinux OpenRISC port

While compiling uClinux today I succeeded with some source modifications.

ERROR:
/home/ant/project/or1k/uclinux/uClinux-2.0.x/include/asm/board.h:63: Error: junk at end of line, first unrecognized character is `/'
SOLUTION:
include/asm/board.h: only /* */ comments are allowed. // comments should be removed

ERROR:
head.S:231: Error: junk at end of line, first unrecognized character is `,'
SOLUTION:
arch/or32/kernel/head.S: remove last coma from the line 231: .section .romvec, "ax",

ERROR:
/home/ant/project/or1k/uclinux/uClinux-2.0.x/include/linux/skbuff.h:424: error: label at end of compound statement
SOLUTION:
in include/linux/skbuff.h, at the lines 423 and 410, add ; after head

ERROR:
sched.c:440: error: label at end of compound statement:
SOLUTION:
in kernel/sched.c, at line 439 add ; after case TASK_RUNNING:

ERROR:
tcp_input.c:2349: error: label at end of compound statement
SOLUTION
in net/ipv4/tcp_input.c, at line 2347 add ; after default:

ERROR:
udp.c:202: error: label at end of compound statement
SOLUTION:
in net/ipv4/udp.c, at line 201 add ; after next:

ERROR:
filemap.c:775: error: label at end of compound statement
SOLUTION:
in mmnommu/filemap.c, at line 773 add ; after case 0:

ERROR:
or32-uclinux-ld -T arch/or32/board/rom.ld arch/or32/kernel/head.o init/main.o init/version.o \
arch/or32/kernel/kernel.o arch/or32/mm/mm.o arch/or32/board/board.o kernel/kernel.o fs/fs.o ipc/ipc.o net/network.a mmnommu/mm.o \
fs/filesystems.a \
drivers/block/block.a drivers/char/char.a drivers/net/net.a \
/home/ant/project/or1k/uclinux/uClinux-2.0.x/lib/lib.a arch/or32
/lib/lib.a /opt/or32-uclinux/lib/gcc/or32-uclinux/3.4.4/libgcc.a -o linuxor32-uclinux-ld: error: no memory region specified for loadable section `.rodata.str1.1'
make: *** [linux] Error 1
SOLUTION:

in arch/or32/board/rom.ld add entry for .rodata.str1.1 and .rodata.cst4 similar to that for .rodata. as follows:

.rodata.str1.1 :
{
*(.rodata.str1.1)
__etext = . ;
} > flash

.rodata.cst4 :
{
*(.rodata.cst4)
__etext = . ;
} > flash

With these modifications the application compiled and linked successfully.

Thursday, March 1, 2007

Building with GNU toolchain

I was trying to build OpenRISC architectural simulator today. Configure task passed fine, but on the make stage I've got the following error:

configure.in:11: version mismatch. This is Automake 1.9.6,
configure.in:11: but the definition used by this AM_INIT_AUTOMAKE
configure.in:11: comes from Automake 1.9.5. You should recreate
configure.in:11: aclocal.m4 with aclocal and run automake again.
WARNING: `automake-1.9' is needed, and you do not seem to have it handy on your
system. You might have modified some files without having the
proper tools for further handling them. Check the `README' file,
it often tells you about the needed prerequirements for installing
this package. You may also peek at any GNU archive site, in case
some other package would contain this missing `automake-1.9' program.
make[3]: *** [Makefile.in] Error 1
make[3]: Leaving directory `/home/ant/project/or1k/or1ksim/cpu/or32'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/ant/project/or1k/or1ksim/cpu'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/ant/project/or1k/or1ksim'

After issuing aclocal command the build succeeded. WTF?
I'm not very familiar with these tools, so I googled for 'aclocal'. Here's what I found:

The aclocal program creates the file `aclocal.m4' by combining stock installed macros, user defined macros and the contents of `acinclude.m4' to define all of the macros required by `configure.in' in a single file. aclocal was created as a fix for some missing functionality in Autoconf.

It seems to me that autoconf should include aclocal functionality. I might be missing something here but shouldn't the tool be more intelligent?

Friday, February 2, 2007

getters and setters

Recently I had to cleanup some very old Java code. Just simple batch applications that take some data from one database and transfer it to another database. I noticed a funny "pattern" in the legacy code: one static method iterates the ResultSet and collects the results into a Vector using String[], like:

List list = new ArrayList();
while (rs.next()){
String [] row = String[3];
row[0] = rs.getString(1);
row[1] = rs.getString(2);
row[2] = rs.getString(3);
list.add(row);
}

The second method then iterates the results, performs some calculations, and inserts new values to database:

for(int i = 0; i < list.size(); i++){
String[] row = (String[])list.get(i); // yaaggghhhhhh!?!
....
}

Smells like C... Personally I have nothing against C, but not inside Java code. I'd better introduce a bean class to encapsulate the values.

OK. let it be:

// as all the logic fits into one class i'd better make this class private
private class MyBean {
String a;
String b;
String c;
MyBean(String _a, String _b, String _c){
a = _a; b = _b; c = _c;
}
}

What I realized now - no point of having getters and setters for the inner class' members. Why?
1) This is used only inside the host class, thus no encapsulation needed.
2) Getters and setters will just flood the source code without bringing any value and making the code less readable.
Instead, I set default access to the bean class members.

The moral is that getters and setters aren't absolutely necessary for simple code. I believe this is trivial, but some people wouldn't agree I guess.

Take care :)

Thursday, February 1, 2007

What if... C#?

Programming covers many different business areas and therefor it seems narrowminded to me to be sticked 100% to Java and JVM. Today I thought, what if I will have to develop something in C#? I have no expirience with .NET yet. But I'm so used to the programming practices/tools that I gained with Java - like Ant, JUnit, cruisecontrol, O/R mapping, and Spring Framework of course.
While googling for a while I found that all the tools or some similar exist for .NET:

NHibernate
NUnit
NMock
NCover
log4net
Spring.NET

With such set of tools it seems that there's almost no difference in Java vs C# programming - just a matter of syntax - moreover it is similar for both.

Disqus for Code Impossible