M201370367 / beanshell2

Automatically exported from code.google.com/p/beanshell2
0 stars 1 forks source link

Support of java 1.5 lang features (generics, enum, annotations) #24

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Write some .java source, which contains generics classes, enum, annotations.
2. Read .java source into string value and call BeanShell.evalute().
 -> Get Exeption

As I understand beanshell currently not supported this.
May be, it will be hard to implement this features, especially generics.

Do you plan this in future?

Original issue reported on code.google.com by vitr...@gmail.com on 9 Jan 2009 at 1:28

GoogleCodeExporter commented 9 years ago
There are no need in generics, because bsh is dynamic. Generics only useful for 
static type checking.

Original comment by LaialNar...@gmail.com on 5 May 2011 at 1:40

GoogleCodeExporter commented 9 years ago
Even if this is perfectly valid it would be helpful is generics syntax would be 
accepted by the parser so that you can switch between bsh and java (e.g. for 
testing).

Original comment by pejob...@gmail.com on 5 May 2011 at 5:57

GoogleCodeExporter commented 9 years ago
Yes, I would be perfect if bsh parser accept a generics syntax!
1. Modern Java code have tons of generics and enums. To run that code under bsh 
- I need completely rewrite it: remove generics, enums and annotations (ie. 
move back).
I can't copy some peace of code and run under bsh - it required to be 
rewritten. Write ones and run anywhere - this not unfortunately true for bsh 
:(. 
2. If applications that supports some user scripting for extending it 
functionality - users start to learn java. And what tutorials they see? Right - 
Java 1.5 syntax. In most of forums java code is given in Java 1.5 syntax. IMHO 
not supporting it (may be like ignoring in case of generics or annotations) - 
its a problem in using/popularity of bsh.

Original comment by vitr...@gmail.com on 6 May 2011 at 7:33

GoogleCodeExporter commented 9 years ago
Perhaps we could explicity state that generics are not checked like e.g. by 
javac. So you could create and use code in bsh2 which is no valid java code 
(w.r.t. generics).

I think we should separate the issue "defining enums" - the class generation 
part in beanshell2 has already issues which can't be worked around, so a major 
rewrite in this part is already needed. This should be done in a v3 branch - 
and then with enum/annotation support (or at least keeping these in mind).

So in this issue we could extend the grammar supporting generics and 
annotations (but ignoring them). And another issue/feature the rewrite of the 
class generation part is adressed.

Original comment by pejob...@gmail.com on 6 May 2011 at 8:48

GoogleCodeExporter commented 9 years ago
To keep this up-to-date: Parsing of generics was added with r30 and r31.

Original comment by pejob...@gmail.com on 16 Nov 2011 at 9:38

GoogleCodeExporter commented 9 years ago
Any chance of getting enum support any time soon?

Original comment by jpsut...@gmail.com on 22 Nov 2011 at 1:55

GoogleCodeExporter commented 9 years ago
@jpsutton
Which kind of "support" do you mean? Defining enums from beanshell?

Original comment by pejob...@gmail.com on 22 Nov 2011 at 2:08

GoogleCodeExporter commented 9 years ago
Yes.  However, I just now saw your previous comment where you stated that it 
would require a major re-write.  Question answered. :)

Original comment by jpsut...@gmail.com on 23 Nov 2011 at 8:01

GoogleCodeExporter commented 9 years ago
Hi

Regarding generics support, I've found that entering the following command 
works fine:

Vector<String> v = new Vector<String>();

but as soon as I have more that one templated class, it produces an error:

Hashtable<String,Integer> h = new Hashtable<String,Integer>();
// Error: Parser Error: Parse error at line 1, column 97.  Encountered: ,

I would like to help to make BeanShell support this as well, but I have no idea 
how or where to start. I've got the source code up and running ...

Original comment by robert.f...@gmail.com on 4 Jan 2012 at 7:46

GoogleCodeExporter commented 9 years ago
ReHallo

I want to recall the second part of my previous post, because after some very 
heavy digging I found what I was looking for and I even was able to adjust it 
by myself :-D

I had to modify the file "bsh.jjt" like this and rebuild everything:

void TypeArguments() :
{ }
{
    "<" <IDENTIFIER> 
        ( "," <IDENTIFIER> )*
        ">"
}

greetings from Luxembourg
Bob

Original comment by robert.f...@gmail.com on 4 Jan 2012 at 8:29

Attachments:

GoogleCodeExporter commented 9 years ago
Bob's fix works perfectly! Thanks!

Original comment by wech1...@gmail.com on 17 Oct 2013 at 9:50