IKVM 编程武林之.NET派的北冥神功

在编程武林中,Java派成立较久底子雄厚,虽然掌门人Sun已经老态龙钟,镇山之技的Java语言已经被后进的新秀.NET派的C#压得喘不过气来,甚至有时候Sun老大还得跑到.NET派潜伏学艺。但是百足之虫,死而不僵,一众Java派的拥趸们自认虽然Java渐渐技不如人,但是Java派成立日久,从Java演化过来的七十二门绝技绝非武林暴发户.NET派所能比拟,其中几大支派如apache,springsource各有绝技,而衍生出的帮会、黑社会等等更是不计其数,.NET派望尘莫及。

然而江湖传言有不世神功叫北冥神功,“北冥有鱼,其名为鲲,鲲之大,不知其几千里也……”,能够容纳几千里的大鱼必定是非常广阔的海洋,因而北冥神功正是寓含了广大恢宏之意,也体现了神功的威力。“可以吸取他人的内力以供己用,是迅速提升功力的捷径。内力既厚,天下武功无不为我所用,犹如北冥,大舟小舟无不载,大鱼小鱼无不容。”

.NET派的几位高人闭关苦练,竟然悟出北冥神功,此神功后曰:IKVM.NET.

江湖后辈小子Ray Linn偶习此神功,得心得一二,不敢自珍,特此记之,以壮大我.NET门派,千秋万代,一统江湖。

那日Ray偶来到apache支派,却看到Apache弟子们各施绝技,好不热闹. Ray对Apache绝技手痒已久,想来得习IKVM.NET已有时日,斗胆上前叫阵。迎战者哪Apache派中的小弟子,江湖人称:commons.collection.

二人拳脚来去,Ray却懒得与之多动手脚,随即默念真言:
ikvmc -assembly:commons -target:library -version:1.0.0.0 commons-collections-3.2.1.jar  


collection陡然萎靡在地,想是一身内功尽被Ray所吸去,Apache派人等尽皆失色,“我等苦练十余载,内力尽为汝一夕取去”,莫敢上前。

Ray回转.NET派,试练collection的神功,借助IKVM.OpenJDK.Core之神器,神功即成,试演如下:

using System;

using org.apache.commons.collections;
using org.apache.commons.collections.functors;

namespace MyLib
{
    class Program
    {
        static void Main(string[] args)
        {
            String name = "Tim";
            Predicate nameJohn = new EqualPredicate( "John" );
            Predicate nameTim = new EqualPredicate( "Tim" );
            Predicate instanceString = new InstanceofPredicate(typeof(String) );
            Predicate instanceDouble = new InstanceofPredicate(typeof(Double));
            Console.Out.WriteLine( "Is Name John?: " + nameJohn.evaluate( name ) );
            Console.Out.WriteLine("Is Name Tim?: " + nameTim.evaluate(name));
            Console.Out.WriteLine( "Is this a String?: " + instanceString.evaluate( name ) );
            Console.Out.WriteLine( "Is this a Double?: " + instanceDouble.evaluate( name ) );

        }
    }
}



相较原有神功:
import org.apache.commons.collection.Predicate;
import org.apache.commons.collection.functors.*;
String name = "Tim";
Predicate nameJohn = new EqualPredicate( "John" );
Predicate nameTim = new EqualPredicate( "Tim" );
Predicate instanceString = new InstanceofPredicate( String.class );
Predicate instanceDouble = new InstanceofPredicate( Double.class );
// Testing all predicates for "Tim"
System.out.println( "Is Name John?: " + nameJohn.evaluate( name ) );
System.out.println( "Is Name Tim?: " + nameTim.evaluate( name ) );
System.out.println( "Is this a String?: " + instanceString.evaluate( name ) );
System.out.println( "Is this a Double?: " + instanceDouble.evaluate( name ) );


竟然绝无二致。

偌大Java江湖,从此为我.NET所用,哇哈哈。

你可能感兴趣的:(jvm,编程,.net,asp.net,Ruby)