The Artima Developer Community
Sponsored Link

Java Buzz Forum
Scripting Language Specific ClassLoader

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Toyokazu Tomatsu

Posts: 66
Nickname: tomatsu
Registered: Jul, 2003

Toyokazu Tomatsu is a developer of Pnuts.
Scripting Language Specific ClassLoader Posted: Oct 6, 2006 11:38 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Toyokazu Tomatsu.
Original Post: Scripting Language Specific ClassLoader
Feed Title: Pnuts Addict
Feed URL: http://jroller.com/tomatsu/feed/entries/rss
Feed Description: Toyokazu Tomatsu's Weblog
Latest Java Buzz Posts
Latest Java Buzz Posts by Toyokazu Tomatsu
Latest Posts From Pnuts Addict

Advertisement
When I developed PnutsClassLoader, I realized that scripting-language-specific ClassLoader is another interface to scripting languages. GroovyClassLoader is one. I am not sure if Jython has such ClassLoader. As an experiment, I wrote JavaCompilerClassLoader that parses a Java source file and compiles it on-the-fly using JSR199 API.

By the way, in my latest project, I used PnutsClassLoader to define classes in Pnuts. For instance,

    package mypackage
    import java.util.HashMap

    class int_map extends HashMap {
        get(key){
          if ((v = super.get(key)) == null){
            super.put(key, v = new int[1])
          }
          v[0]
        }
        put(key, value){
          if ((v = super.get(key)) == null){
            super.put(key, v = new int[1])
          }
          v[0] = value
        }
    }
This class is defined in "mypackage/int_map.pnc" ; ".pnc" is the standard extension for class definition files in Pnuts. I put this file in a WAR file. With this class script, it was easier to count items in a hash table. e.g.
    total = new mypackage.int_map()
    total[key] += count

Read: Scripting Language Specific ClassLoader

Topic: Spring 2.0 released Previous Topic   Next Topic Topic: Getting Tarpitted

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use