Class loading

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Class loading

VVenkataKrishnan

Hei,

Interpreter i = new Interpreter();
i.eval("String s = new String(\"Hello World!\");");

In the above Java statement i wish to know how the beanshell invokes the class "String" without its package being specified. How does it associates the namespace.

I have a small requirement like this, to dynamically invoke simple Java statements and invoke Java classes dynamically. I have a small interpreter developed for this. As the requirement is urgent, although i had read few sources of beanshell i would like to get the answer from the experienced than by finding all my myself.

Thanks

V
------------------------------------------------------------------------------
This SF.net email is sponsored by

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers
Reply | Threaded
Open this post in threaded view
|

Re: Class loading

VVenkataKrishnan

thanks for you reply, harlon. I would like to know how the packages are run before executing the java statement? any idea where to find the source in the beanshell library.
Is the package finding is like this, iterate the available packages using the java.lang.Package and match each package with the input class name string, for ex "String" or "InputStream" or "JButton".

Thanks
V

---------------------


The interpreter maintains a global import list, just like a compiler.
If an interpreter is created and a series of import commands run
before a statement like that is seen, the interpreter uses that import
list to resolve unqualified classnames. I forget where the code to do
that is, but there is no magic. There is also a small list of default
packages that are always imported, I think.

On Wed, Aug 18, 2010 at 9:35 PM,  <[hidden email]> wrote:
>
> Hei,
>
> Interpreter i = new Interpreter();
> i.eval("String s = new String(\"Hello World!\");");
>
> In the above Java statement i wish to know how the beanshell invokes the
> class "String" without its package being specified. How does it associates
> the namespace.
>
> I have a small requirement like this, to dynamically invoke simple Java
> statements and invoke Java classes dynamically. I have a small interpreter
> developed for this. As the requirement is urgent, although i had read few
> sources of beanshell i would like to get the answer from the experienced
> than by finding all my myself.
>
> Thanks
>
> V
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by
>
> Make an app they can't live without
> Enter the BlackBerry Developer Challenge
>
http://p.sf.net/sfu/RIM-dev2dev
> _______________________________________________
> Beanshell-developers mailing list
> [hidden email]
>
https://lists.sourceforge.net/lists/listinfo/beanshell-developers
>
>

------------------------------------------------------------------------------
This SF.net email is sponsored by

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers
Reply | Threaded
Open this post in threaded view
|

Re: Class loading

Alexey Zinger
In reply to this post by VVenkataKrishnan
If I'm not mistaken, BeanShell simply pre-imports certain packages (java.lang.*, java.util.*, java.io.*?).
 
Alexey
http://azinger.blogspot.com
http://bsheet.sourceforge.net
http://wcollage.sourceforge.net



From: "[hidden email]" <[hidden email]>
To: [hidden email]
Sent: Thu, August 19, 2010 12:35:56 AM
Subject: [Beanshell-dev] Class loading


Hei,

Interpreter i = new Interpreter();
i.eval("String s = new String(\"Hello World!\");");

In the above Java statement i wish to know how the beanshell invokes the class "String" without its package being specified. How does it associates the namespace.

I have a small requirement like this, to dynamically invoke simple Java statements and invoke Java classes dynamically. I have a small interpreter developed for this. As the requirement is urgent, although i had read few sources of beanshell i would like to get the answer from the experienced than by finding all my myself.

Thanks

V


------------------------------------------------------------------------------
This SF.net email is sponsored by

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers
Reply | Threaded
Open this post in threaded view
|

Re: Class loading

David Lee
If you want programming help to accomplish the same thing, you should look at the Class and ClassLoader API reference.
This is the underlying glue that lets you adjust the class path and dynamically locate and load classes.

I warn, however, that if your project is in such a rush that you may find the complexity of getting these API's is high.
I consider mucking with ClassLoader "Advanced" Java programming and it takes quite a while to learn it and get it to work right.
You may not be pleased if you expect to get an implementation to work "urgently".

-David





On 8/19/2010 9:21 AM, Alexey Zinger wrote:
If I'm not mistaken, BeanShell simply pre-imports certain packages (java.lang.*, java.util.*, java.io.*?).
 
Alexey
http://azinger.blogspot.com
http://bsheet.sourceforge.net
http://wcollage.sourceforge.net



From: [hidden email] [hidden email]
To: [hidden email]
Sent: Thu, August 19, 2010 12:35:56 AM
Subject: [Beanshell-dev] Class loading


Hei,

Interpreter i = new Interpreter();
i.eval("String s = new String(\"Hello World!\");");

In the above Java statement i wish to know how the beanshell invokes the class "String" without its package being specified. How does it associates the namespace.

I have a small requirement like this, to dynamically invoke simple Java statements and invoke Java classes dynamically. I have a small interpreter developed for this. As the requirement is urgent, although i had read few sources of beanshell i would like to get the answer from the experienced than by finding all my myself.

Thanks

V

------------------------------------------------------------------------------ This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev
_______________________________________________ Beanshell-developers mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/beanshell-developers


-- 
David A. Lee
[hidden email]
http://www.xmlsh.org

------------------------------------------------------------------------------
This SF.net email is sponsored by

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers