Visual J#

考えてみたら、VisualStudio2005にVisual J#ってのがついていたのを思い出しました。

#そういえば、使ってみようとか、考えたことなかったなぁ。

ということで、早速スターターキットのプロジェクトを開けてみると、電卓のサンプルが作られました。
電卓本体のコードがこんな感じです。

package calculator;

import calculator.ui.CalculatorForm;
import calculator.model.Engine;
import System.Windows.Forms.Application;

/**
 * The main class
 */
public class Calculator
{
	/**
	 * The main entry point
	 */
	/** @attribute System.STAThread() */
	public static void main(String[] args)
	{
		// Create the main form class
		CalculatorForm view = new CalculatorForm();

		// Set the view as observer
		Engine.getDisplay().addObserver(view);
		Engine.reset();

		// Run the form
		Application.EnableVisualStyles();
		Application.Run(view);
	}
}

C#のコードに似てるけど、文法は確かにJavaっぽいです。

#そもそも、はてな記法シンタックス・ハイライトにJavaを指定して、きれいに表示されちゃいました。

他のクラスもみてみましょう。

package calculator.model;

import calculator.model.mode.*;
import java.util.Observable;

public class Display extends Observable
{

おや?この

import java.util.Observable;

って何?ひょっとして、Javaのクラスライブラリが直接インポートできちゃうの?
なんて思ったら、そんなことはありませんでした。

Visual J# Reference
Visual J# Class Library



The J# Class Libraries is Microsoft's implementation of the JDK 1.1.4 specification. Most classes implement functionality that is subset or equivalent to JDK1.1.4 whereas some implement functionality that is subset or equivalent to 1.2. Visual J# 2005 also supports many of the Microsoft Extensions defined in Visual J++ 6.0, such as com.ms.lang.Delegate. For a complete list of which features are supported, see Supported Class Libraries. For a list of the features that Visual J# does not support, see Unsupported Class Libraries and Features.

The J# Class Libraries are built on top of the .NET Framework. The root class of the J# Class Libraries, java.lang.Object, is derived from Object. This means that all J# objects can be used where a .NET object is expected, and vice versa. For example, a java.lang.String can be inserted into a ArrayList. Conversely, a String can be inserted into a java.util.Vector. For more information on the relationship between Visual J# and the .NET Framework, see Visual J# Architecture.

For Visual J# 2005, most packages defined by the Java 1.1.4 specification are supported, but only the most important classes in the following packages are documented at this time:

だそうです。イマドキJDK1.1.4はないでしょう!

それから、また発見したことがあったのですが、Java .classファイルをMSILに変換するコンバートツールが標準でついているらしいです。