Bookmark Topic Watch Topic
  • New Topic

how to convert a string to a java expression ??  RSS feed

 
Oni Anand
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi,
i have a following string :
"if ( ((X < 20 ) && ( Y > 50)) | | ( Z ==56) ) "
i want to convert it to a java condtional expression...how can i do that ??
as a matter of fact i want to know is there any generic way to convert any string to a corresponding java expression or statement or variable declaration.
thanks
Oni
I am sorry if you read this question again
 
Peter Tran
Bartender
Posts: 783
  • Mark post as helpful
  • send pies
  • Report post to moderator
I don't this is possible. A JAVA expression is compiled into bytecode and evaluated by the JVM. What you're proposing to do is have a psuedo-JIT inside your code. If you figure out how, let me know!
-Peter
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Report post to moderator
Let's see if I can get this straight... what you are proposing is to take a String or even a whole file full of Strings and feed them into some program (let's call it javac.exe for arguments sake) and then have this javac.exe produce executable byte code? Sounds completely implausable.
 
Peter Tran
Bartender
Posts: 783
  • Mark post as helpful
  • send pies
  • Report post to moderator
I'm closing this topic here, because Oni has posted it about 3 other forums.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!