Tuesday, March 4, 2008

Customizable Closure with OpenJDK MLVM and javac

The customizable closure code listed below, take advantage of following,
  1. Closure data types are converted to inner classes at compile time.
  2. AnnonymousClassLoader in MLVM, allows us to load multiple definitions of same class in the same instance of the class loader at run time.
Code:
import java.dyn.AnonymousClassLoader;

public class CustomizableClosure {

static private {String => void} welcomeClosure =
{ String name => System.out.println(name + ", " + shortWelcome);};

static String shortWelcome = " Welcome to closure...";
static String detailedWelcome =
" Welcome to MLVM closure customization..Experience the power of AnonymousClassLoader...";

public static void main(String[] args) throws Exception {
CustomizableClosure.testSimpleClosure();
CustomizableClosure.testCustomizableClosure();
}

static void testSimpleClosure() {
System.out.println("=================");
System.out.println("Before customization..");
welcomeClosure.invoke("Dear bob");
System.out.println("=================");
}

static void testCustomizableClosure() throws Exception {
AnonymousClassLoader acl = new AnonymousClassLoader();

acl.setClassFile(welcomeClosure.getClass());
Class hostClass = CustomizableClosure.class;

Class acls = welcomeClosure.getClass();
acl.putSymbolPatch("shortWelcome", "detailedWelcome");
acls = acl.loadClass();

{String => void} obj = ({String => void}) acls.newInstance();
System.out.println("================");
System.out.println("After customization..");
obj.invoke("Dear bob");
System.out.println("================");
}
}
Output:

=================
Before customization..
Dear bob, Welcome to closure...
=================
================
After customization..
Dear bob, Welcome to MLVM closure customization..Experience the power of AnonymousClassLoader...
=================

OK, what's going on?
  1. {String => void} welcomeClosure = { String name => System.out.println(name + ", " + shortWelcome);} this closure snippet is converted to inner class at compile time.
  2. In method "testSimpleClosure", we are executing closure code as is.
  3. In method "testCustomizableClosure", we take closure (compiled inner class) as base template, customize it (by changing welcome text) at run time and execute it.
Step by step instructions on how to build and run Customizable Closure code.
  1. Build OpenJDK and Hotspot.
  2. Apply MLVM patch and rebuild Hotspot.
  3. Download javac for closures from javac.info
  4. Prepend MLVM AnonymousClassLoader.class and javac.jar to bootclasspath of java and javac. In my local machine, i used following commands for compilation and execution.
  • javac -J-Xbootclasspath/p:/share/software/OpenJDK/closures-2008-02-12/lib/javac.jar:/share/software/OpenJDK/mlvm/bootcp -source 7 -d classes/ CustomizableClosure.java
  • java -Xbootclasspath/p:/share/software/OpenJDK/closures-2008-02-12/lib/javac.jar:/share/software/OpenJDK/mlvm/bootcp -cp classes CustomizableClosure

    59 comments:

    Anonymous said...

    [B]NZBsRus.com[/B]
    Forget Sluggish Downloads With NZB Downloads You Can Quickly Search HD Movies, Console Games, MP3s, Software and Download Them @ Accelerated Rates

    [URL=http://www.nzbsrus.com][B]Usenet Search[/B][/URL]

    Anonymous said...

    Synchronize Our Risqu‚ Prices at www.Pharmashack.com, The Foremost [b][url=http://www.pharmashack.com]Online Chemist's snitch on [/url][/b] To [url=http://www.pharmashack.com]Buy Viagra[/url] Online ! You Can also Breathing-space upon August Deals When You [url=http://www.pharmashack.com/en/item/cialis.html]Buy Cialis[/url] and When You You [url=http://www.pharmashack.com/en/item/levitra.html]Buy Levitra[/url] Online. We Also Be struck mad a Jammed of Generic [url=http://www.pharmashack.com/en/item/phentermine.html]Phentermine[/url] As a armed forces to Your Intake ! We Hawk Robust squiffy envisage [url=http://www.pharmashack.com/en/item/viagra.html]Viagra[/url] and Also [url=http://www.pharmashack.com/en/item/generic_viagra.html]Generic Viagra[/url] !

    Anonymous said...

    Infatuation casinos? into this unripened [url=http://www.realcazinoz.com]casino[/url] advisor and spurious online casino games like slots, blackjack, roulette, baccarat and more at www.realcazinoz.com .
    you can also pore finished our untrained [url=http://freecasinogames2010.webs.com]casino[/url] guide at http://freecasinogames2010.webs.com and seize dedicated folding bread !
    another lone [url=http://www.ttittancasino.com]casino spiele[/url] district is www.ttittancasino.com , because german gamblers, rebel at authorization online casino bonus.

    Anonymous said...

    Message27, http://www.arlo.net/massacree/ buy viagra online, txmu0, http://www.arlo.net/fccgb/ viagra without prescriptions, pkrx3, http://www.arlo.net/fccgb/notes/ generic viagra online, yoyt1, http://www.arlo.net/bytes/ cheap viagra, olsj9, http://www.arlo.net/live/ viagra sale online

    Anonymous said...

    buy viagra online buy viagra super active - like viagra for women

    Anonymous said...

    generic viagra forum for generic viagra - where to buy viagra online us

    Anonymous said...

    viagra online without prescription is the viagra you buy online real - order viagra london

    Anonymous said...

    discount viagra buy viagra online us no prescription - viagra online from us generic

    Anonymous said...

    generic viagra female viagra buy online us - viagra rxlist

    Anonymous said...

    [url=http://www.onlinecasinos.gd]online casino[/url], also known as accepted casinos or Internet casinos, are online versions of commonplace ("chunk and mortar") casinos. Online casinos support gamblers to get ingredient in and wager on casino games from start to empty the Internet.
    Online casinos typically invite odds and payback percentages that are comparable to land-based casinos. Some online casinos contend higher payback percentages in the servicing of stake defender games, and some kind-hearted special-interest group payout consequence profit audits on their websites. Assuming that the online casino is using an aptly programmed unsystematically congregate generator, substance games like blackjack preoccupy an established forebears edge. The payout sculpt up on account of without looking at these games are established gone and forgotten the rules of the game.
    Uncounted online casinos take on in non-performance or get hold of their software from companies like Microgaming, Realtime Gaming, Playtech, Worldwide Shift Technology and CryptoLogic Inc.

    Anonymous said...

    viagra online without prescription buy generic viagra online us - buy viagra online australia no prescription

    Anonymous said...

    buy soma online soma medication for migraines - buy soma online mastercard

    Anonymous said...

    cheap soma soma bras usanapolis - soma food trucks

    Anonymous said...

    buy soma online pharmacy soma no prescription - soma online order

    Anonymous said...

    buy soma soma drug breastfeeding - will soma show 10 panel drug test

    Anonymous said...

    top [url=http://www.001casino.com/]online casino[/url] brake the latest [url=http://www.realcazinoz.com/]casino online[/url] free no consign hand-out at the best [url=http://www.baywatchcasino.com/]www.baywatchcasino.com
    [/url].

    Anonymous said...

    soma online buy 120 soma online - what is generic soma

    Anonymous said...

    buy soma soma medication overdose - soma intimates online coupon codes

    Anonymous said...

    soma online buy soma muscle relaxant online - order soma from usa

    Anonymous said...

    buy soma soma no prescription - buy soma us

    Anonymous said...

    buy cialis online buy cialis online legal - cialis daily basis

    Anonymous said...

    buy tramadol no prescription overnight tramadol for dogs cough - tramadol 50 mg is it a narcotic

    Anonymous said...

    generic tadalafil cialis 20 coupon - get cialis online usa

    Anonymous said...

    buy tramadol online tramadol dogs dosage dogs tramadol - tramadol hcl 50 mg migraines

    Anonymous said...

    buy tramadol online tramadol hcl 75mg - buy tramadol online in australia

    Anonymous said...

    buy tramadol online can you overdose tramadol - tramadol overdose 200mg

    Anonymous said...

    generic xanax xanax junkie - is 1 mg of xanax a lot

    Anonymous said...

    generic xanax xanax overdose while pregnant - xanax bars

    Anonymous said...

    buy tramadol next day tramadol discount - tramadol withdrawal fatigue

    Anonymous said...

    xanax online side effects of xanax 0.25mg - can u overdose xanax

    Anonymous said...

    xanax online xanax drug description - yellow xanax effects

    Anonymous said...

    hello buy cheap valtrex online no prescription - cheap valacyclovir http://www.valtrexonlinesale.net/#cheap-valacyclovir , [url=http://www.valtrexonlinesale.net/#valtrex-drug ]valtrex drug [/url]

    Anonymous said...

    aev doxycycline no prescription - buy doxycycline online http://www.doxycyclineonlinerx.net/#buy-doxycycline-online , [url=http://www.doxycyclineonlinerx.net/#doxycycline-antibiotic ]doxycycline antibiotic [/url]

    Anonymous said...

    carisoprodol 350 mg order carisoprodol no prescription - carisoprodol 350 mg used for

    Anonymous said...

    carisoprodol 350 mg carisoprodol drug uses - carisoprodol soma drug test

    Anonymous said...

    buy carisoprodol carisoprodol usp 350 mg - carisoprodol generic for soma

    Anonymous said...

    cheap cialis 20mg ho comprato cialis online - cialis tolerance

    Anonymous said...

    buy cialis online cialis daily price - generic cialis no-rx

    Anonymous said...

    http://landvoicelearning.com/#57594 cheap tramadol with cod - tramadol no prescription overnight shipping

    Anonymous said...

    20000 :) Buy Neurontin - buy gabapentin 300mg http://www.neurontinonlinecheap.net/#Buy-Neurontin, [url=http://www.neurontinonlinecheap.net/#Generic-Gabapentin]Neurontin 300mg[/url]

    Anonymous said...

    buy klonopin online klonopin wafers dosage forms - klonopin for depression

    Anonymous said...

    buy tramadol cod tramadol 50 mg for humans - tramadol dosage greyhounds

    Anonymous said...

    http://landvoicelearning.com/#74967 buy tramadol online without prescriptions usa - is ordering tramadol online illegal

    Anonymous said...

    http://landvoicelearning.com/#74967 buy tramadol online mastercard overnight - ordering tramadol online legal

    Anonymous said...

    http://landvoicelearning.com/#62431 tramadol buy online no prescription - ultram tramadol ingredients

    Anonymous said...

    klonopin mg klonopin side effects for women - klonopin anti anxiety

    Anonymous said...

    tramadol buy tramadol 100mg - tramadol online no prescription needed

    Anonymous said...

    klonopin no prescription klonopin withdrawal success stories - klonopin xanax high

    Anonymous said...

    http://www.integrativeonc.org/adminsio/buyklonopinonline/#8491 2mg klonopin compared 2mg xanax - 2mg klonopin suboxone

    Anonymous said...

    order tramadol online overnight tramadol withdrawal method - tramadol legal to order online

    Anonymous said...

    http://southcarolinaaccidentattorney.com/#51643 medication soma carisoprodol - carisoprodol on drug test

    Anonymous said...

    generic carisoprodol carisoprodol 350 mg tablets information - carisoprodol 350 mg picture

    Anonymous said...

    buy carisoprodol no prescription carisoprodol 350 mg blood pressure - buy vicodin online no prescription overnight

    Anonymous said...

    carisoprodol 350 mg long carisoprodol your system - uses for carisoprodol 350 mg

    Anonymous said...

    Hi, phentermine cost - buy phentermine 37.5 http://www.et2trailer.com/, [url=http://www.et2trailer.com/]purchase phentermine[/url]

    Anonymous said...

    Researching for the best lender is obviously present fast financial loan approval, 6 months for you to 10 years. The lender can transfer your money in your bank account within One day. They need to come up with the particular deleveraging of the plan, and must function as the implementation of your program". instant payday loans uk It had become a thing with past to satisfy various difficult procedures to secure of cash after you needed badly!

    Anonymous said...

    So in lieu of strolling at a constant speed for say an hour,
    you would change items up by alternating short bursts
    of intense walking for say a minute followed by a recovery time period with
    slower strolling right after each and every extreme
    period. Just continue to keep alternating for
    20 minutes to start and add time as you grow to
    be far more match. It is possible to use interval education with all
    phases from thegreen coffee bean extract to enhance your success.


    Also once you do any kind of work out it is actually strongly suggested that you drink
    lots of water in advance of for the duration of and right after to maintain your whole body effectively hydrated.

    Anonymous said...

    [url=http://www.zolpidemrxforsale.net/]buy zolpidem [/url] ambien no prescription - zolpidem online - buy cheap generic ambien online - http://www.zolpidemrxforsale.net/ [url=http://www.zolpidemrxforsale.net/]ambien without prescription [/url] cheap generic ambien - buy ambien - buy ambien no prescription - http://www.zolpidemrxforsale.net/ [url=http://www.diazepamonlinerx4cheap.net/]order diazepam online [/url] diazepam for sale no prescription - purchase valium online - valium online - http://www.diazepamonlinerx4cheap.net/ [url=http://www.zolpidemrxforsale.net/]buy ambien online no prescription [/url] purchase ambien - buy generic ambien - generic ambien cost - http://www.zolpidemrxforsale.net/

    Anonymous said...

    Blogger: Exploring Software Universe - Post a Comment [url=http://www.imitrex4saleonline.com/]sumatriptan price [/url] sumatriptan no prescription - generic imitrex - buy sumatriptan - http://www.imitrex4saleonline.com/ [url=http://www.cymbaltaonlineoffer.com/]cheap cymbalta online [/url] buy cymbalta no prescription - order cymbalta online - price of cymbalta - http://www.cymbaltaonlineoffer.com/ [url=http://www.imitrex4saleonline.com/]cheap Imitrex[/url] buy sumatriptan online - cheap Imitrex - imitrex for sale [url=http://www.provigilusadiscount.com/]Order Provigil Online[/url] provigil for sale online - Modafinil Online - provigil sale