Sunday, November 20, 2011

Java Generics Capture Conversion

Introduction: Earlier in my article Java Compile Time Method Binding I had promised to explain how type arguments are inferred during invocation of a generic method. However, that would not be of that use without learning how capture conversion works first. So what is capture conversion. Capture conversion is the type conversion when a reference of a generic type is created by passing the type parameters. Its not really that complicated. But it still does require some attention. Note that capture conversion is only required for compile time type checking, nothing is there in the compiled code and nothing happens at runtime.

Thursday, November 3, 2011

Fundamental Semantics of Extensible Business Reporting Language Dimensions

Introduction: In my previous article, I have discussed a broad overview of the concepts of XBRL dimensions. Today I am going to discuss about the semantics of XBRL dimensions. Hope you enjoy reading. This article assumes that the reader has gone through the former article here.

Thursday, October 27, 2011

Fundamentals of Extensible Business Reporting Language Dimensions

What is XBRL dimensions: XBRL dimensions specification is a modular extension for the XBRL specification. It uses the segment and scenario elements of the context to use the elements defined in it to divide the data according to dimensions, as I will explain shortly. The dimension specification is too big to be fully covered in a single article, so in this, I will only discuss the fundamentals and in another, I will explain the other syntactic details. Since the article assumes the reader's prior knowledge of XBRL, the reader is advised to first read the articles on XBRL here.

Saturday, October 22, 2011

Java Compile Time Method Binding

Introduction: It appears to be a simple process to determine which method a particular method invocation refers to, but it still needs pages of documentation in the java language specification to address this, especially to take care of auto-boxing/auto-unboxing and variable arguments. In this article, I will highlight how an actual method is bound at compile time to a particular method invocation.

Thursday, October 13, 2011

Manipulating Java Class Files with ASM 4 - Part Two: Tree API

What is ASM tree API: ASM Tree API is the part of ASM that lets you create/modify the class in memory. The class is viewed as a tree of information. Like the whole class is an instance of ClassNode, which contain a list of FieldNode objects, a list of MethodNode objects etc. This article assumes that the reader has already read the first part here.

Thursday, October 6, 2011

Manipulating Java Class Files with ASM 4 - Part One : Hello World!

What is ASM: ASM is an open source java library for manipulating java byte code. So it has the same purpose as Apache BCEL. As this article assumes that the reader has some knowledge of java class file format, it is advisable to read about it in here. So how is it different from BCEL? Well firstly it allows for an event driven way to manipulate byte code eliminating the need to load the whole class in the memory just to make a small addition. Secondly, it does not have a separate class for every single instruction. Instead, it handles opcodes directly and only has constants representing each. This reduces the size of the library to a great extent. So, ASM is simply lighter and smarter. However, ASM also has a mechanism to deal with class files by loading the whole class into the memory just in case the operation is too complex to be handled through event based processing.

The current stable version of ASM is 3.3. However version 4.0 RC2 is out. So, I am going to discuss that version here.

Thursday, September 29, 2011

A Detailed View of Extensible Business Reporting Language Instance

Introduction: XBRL instance is the XML document that contains the real data in an XML format. This document expects a fundamental knowledge about XBRL, which you can read from my posts here. At this point, I will discuss about an instance document in detail.

Thursday, September 22, 2011

A Detailed View of Extensible Business Reporting Language Taxonomy

This is the second article in the extensible business reporting language series. If you have not read the first one, you can read it here. This article assumes that the reader has already read this previous article. In this article, I will attempt to cover the most important aspects in detail.

Thursday, September 15, 2011

Implementing Aspect Oriented Programming Framework - Java Instrumentation

What is Aspect Oriented Programing: Aspect Orented Programing or AOP is a design pattern or programming practice, in which the code for cross cutting concern is separated out from the main program logic, thus effectively reducing the program complexity. Now what is a cross cutting concern? They are application non-functional requirements that apply to multiple functionalities. A simple example would be logging. Logging is done whenever some predefined things happen (for example a method is invoked). Normally, every method that is invoked would have to contain the code for logging. In AOP, we write the logging code in a separate method may be in a separate class and then configure our AOP framework to do logging whenever a method is invoked. There are so many good tutorials available on AOP, one of which is here. However, in Java SE environment, it certainly requires a change in the method's byte code made by the AOP framework. I will demonstrate how an AOP framework performs load time weaving (changes byte code during runtime).

Thursday, September 8, 2011

Enterprise Java Beans - A Broad Overview

What are Enterprise Java Beans: Enterprise java beans are Java EE server side business layer components. They can be used to develop highly available distributed transactional systems. Like servlets and JSPs are used to develop view components in java EE, EJBs are used to develop business logic. Today, I am not going to discuss how an EJB can be deployed on the server. There are just too many tutorials available on the internet. I will discuss the need to use EJB, where it fits and what it gives. In the recent times, people have preferred Spring framework instead of EJB, the advantage of what is being lightweight. It however needs to be discussed that being lightweight is not the only qualities a business framework needs to have. There is a limit to how much spring can scale. There are also somethings spring simply cannot handle, not at least without external component injected through its AOP framework. Enterprise Java Beans are complex and heavier weight, because they attempt to provide solution to much more complex regime of problems. Also note that, unlike spring, EJB is not a product, its a specification. Which means you would have a choice among many implementations, both proprietary and open source, of EJB; where as there is only one spring.

However, after EJB 3.x, deploying and programming EJBs are easier than doing so with spring... believe me.

Thursday, September 1, 2011

Fundamentals of Extensible Business Reporting Language

What is Extensible Business Reporting Language (XBRL): XBRL is an XML based reporting standard mainly designed for financial reporting. However, just like any XML based format, the XBRL standard is open enough to fit into other purposes as well. Most developed countries use XBRL for all financial reporting purposes. There are many documentation about XBRL which are suited to the accounting professionals and business men. However, there is a scarcity of technical documentation. So, I will explain the essential concept of XBRL in this text. Please note that XBRL specification is a very complex specification and it would require more than one article to explain properly. Please stay tuned for more articles.

The following URL will give an idea about how an XBRL document might look in a human readable view http://www.sec.gov/cgi-bin/viewer?action=view&cik=1419793&accession_number=0001144204-11-051027&xbrl_type=v#

Thursday, August 25, 2011

Manipulating Java Class Files with BCEL - Part Three: More About BCEL

This is the third article in the BCEL series. You can read all here. Since I have covered the basics, I will accumulate the points left now. I will discuss about local variables, fields, methods and jump instructions.

Thursday, August 18, 2011

Manipulating Java Class Files with BCEL - Part Two: Expressions

This is the second article in the series of articles on Apache BCEL. If you have not read part 1, read it here.

Expression Processing: Expressions are key part of a language. In this article, I will discuss how expressions are compiled into java byte code. I will also cover a little bit about compilation process. At the end, I will go through the steps and create a compiler for numerical expression.

Thursday, August 11, 2011

Manipulating Java Class Files with BCEL - Part One : Hello World!

What is BCEL: Apache BCEL or Byte Code Engineering Library is a library that enables simpler manipulation of java byte code. Now the question is, why manipulate byte code? There can be a million of reasons. For example, you might want to insert some profiling code in the class file. Or you might want to write your own language that compiles to java byte code. You can also provide some attractive extension to some framework you are creating. Or you can even be more creative than I am and do something that I cannot think of. But for that, you must first understand how java class files work.

Since it is a BCEL tutorial, get the BCEL library first from here


Manipulating java byte code directly is not trivial in nature, so I decided to break the tutorial into a series. This one is the first - the hello world. Keep in touch to learn more.

Thursday, August 4, 2011

Java Threads - How They Work

What is Thread: A thread is a single sequence of instructions being executed in a java virtual machine. The instructions in two different threads have no mutual ordering, they can execute independent of each other.

How to create a thread: In java, the only way to create a thread is by creating an object of class java.lang.Thread. In reality, we can either extend the Thread class and override the method run(), or we can implement java.lang.Runnable in a separate class and pass it to Thread's constructor. This article is meant for people who have some experience with Thread programming in java. If you do not know how to do thread programming in java, there is a very good tutorial in here.

Saturday, July 30, 2011

An Anatomy of Java Generics

1. What is Generics: Generics is a feature in java language to create parameterized types. A parameterized type is a type with parameters passed to it, mostly to enable compiler to check for errors which otherwise would have been a runtime exception.

For example, let us consider programs below. In the first one, generics is not used. We are using java collection API to store and retrieve objects. In this program, it is impossible for the compiler to know what actually is stored in the collection. It is the programmer's job to take care that the objects stored are of expected type and that they are not cast to a wrong type in the time of retrieval. Not only this takes a lot of nasty boiler plate code, it also obfuscates the purpose of the collection all together. Generics attempts to solve this by passing parameters to type to specify what the types are related to. As we will see.

Thursday, July 28, 2011

Floating Point Numbers

What is a Floating Point Number: There are two ways a decimal/fractional number can be represented in binary form - fixed point and floating point. In a fixed point number, the decimal point is in a fixed arbitrary position which is predefined. For example, in a 32 bit fixed point number, the decimal point may be assumed to be after the 16th bit. So any value represented by the 32 bits needs to be divided by 216 = 65536, to get the value of the decimal number represented by a fixed point.

A floating point number on the other hand has a completely different representation. A floating point number compromises on precision for achieving the following.
  1. Broader range of numbers that it can represent
  2. The precision of the number is fixed, irrespective of its value
  3. Represent special values like infinity and not-a-number
Bit Patterns of a Floating Point Number: As per IEEE 754, the floating point numbers are of two types - 32 bit single precision and 64 bit double precision.

Saturday, July 23, 2011

Java enterprise framework developers' tools

Wanna develop your own framework? Developing your own framework is sure geeky. Fortunately, in Java, doing so is not as difficult as it seems. But, why develop a framework when there are too many of them already available there? Well, firstly its fun, but more importantly, the existing frameworks might not right away give you all you need. In that case, it might be a good idea to at least extend those frameworks to meet your needs.

Please note that there are so many things you can use and my list is definitely not exhaustive. It just gives idea about a few good ones that come bundled with Java SE.

Wednesday, July 20, 2011

Traversing the XPath



What is XPath: XPath is an expression language that points to data represented in an XML document. XPath can point to one or more nodes in an XML document and perform basic arithmetic operations. XPath is a very rich language and selection of nodes can be based on any condition including arithmetic comparisons.

Why is XPath important: XPath is used in many other very important specifications. For example, XML Styling Language Transformation (XSLT), and XPointer (XML Pointer). XML Styling language Transformation can be used to generate one XML from another. It can also be used to generate human readable XHTML documents from an XML document. XPointer itself is used in specifications like XLink. (Which I discussed in earlier posts)

Saturday, July 16, 2011

What's new in Java 7 - Project Coin

What's new in Java 7: Well, its a major version upgrade, there needs to be a lot of things coming up. Of course the most noticeable feature set for a java programmer would be the language level change, i.e. Project Coin. Although the changes are not as major as generics (that came with version 5, which was the time they dropped the "1." from the version number.) or annotations (also came with the same version). But, I guess they are at least as good as auto-boxing.

What is Project Coin: Project Coin or JSR334 is the common JSR that embraces all language level changes that comes in Java 7. I will talk about its features one by one.


Sunday, July 10, 2011

XPointer Primer

In my earlier post on XLink, I have explained that XLink uses XPointer to point to nodes in the XML. So, I decided to write an article on XPointer.

What is XPointer: XPointer is a specification that allows pointing to nodes in an XML. XLink in dependent on XPointer specification, and so is XPath specification, which is used heavily in XSLT(XML Styling Langage Transformation). XPointer is compact and non-XML, and is designed to be able to fit into a URL (in the fragment part).

 

Monday, July 4, 2011

X-Link Extended Links

What is X-Link: X-Link is a specification that allows to link between different XML tags. It is very much like an anchor in HTML, you know the regular <a href="..."></a>. However, X-Link is much more versatile and powerful as we will see.

Unlike HTML anchor tag (which is defined to be able to display a visible link), the use of X-Link is not that limited, and depends on where it is used (Is not all other XML based specifications). As such X-Link specification is not designed to be used on its own, there must be other specifications that define specific rules to use it. It is pretty much like XML itself. XML can be used in many ways, and other standards and specifications define what some XML content means. SOAP and WSDL are two specification that use XML specification. Similarly, Extensible Business Reporting Language is a specification that uses X-Link.