Hi Patrick, Well, Enums have only existed for about 3 or 4 years, so 60-70% of that silence is understandable. =)
I want to get my hands on a specific Enum value. valueOf() is just a way to look up an Enum by its string name, I was hoping that might already be exposed in the API by existing methods. Experimenting again, it looks like the following actually works: ------------------------ use Inline (Java => "STUDY", CLASSPATH => "foo.jar", AUTOSTUDY => 1, STUDY=> ["com.my.company.TokenFSM\$TokenType"], JNI=>1); print com::my::company::TokenFSM::TokenType->valueOf("APOS"); ------------------------ That prints: main::com::my::company::TokenFSM::TokenType=HASH(0x1030567c0) And I can call methods of that object (like ordinal(), name(), etc.), so I'm happy. =) -- Ken Williams Senior Research Scientist Thomson Reuters http://labs.thomsonreuters.com On 8/19/11 8:03 AM, "Patrick LeBoutillier" <patrick.leboutill...@gmail.com> wrote: >Ken, > >Enums might be tricky... I believe this is the first question I've had >about them in over 10 years. >What are you expecting "valueOf" to return? > >Patrick > > >On Thu, Aug 18, 2011 at 5:41 PM, <ken.willi...@thomsonreuters.com> wrote: >> I've got a class like so: >> >> ---------------- >> package com.my.company; >> public class TokenFSM { >> public static enum TokenType { >> ALPHAID, >> APOS >> } >> } >> ---------------- >> >> I'd like to access various enum constants from Perl code, something like >> the following (which doesn't work): >> >> >> ---------------- >> use Inline (Java => "STUDY", >> CLASSPATH => "foo.jar", >> AUTOSTUDY => 1, >> STUDY=> ["com.my.company.TokenFSM"], >> JNI=>1); >> print $com::my::company::TokenFSM::TokenType->valueOf("APOS"); >> ---------------- >> >> That dies with: Can't call method "valueOf" on an undefined value at >>-e >> line 1. >> >> >> Anyone have better fu with this? >> >> -Ken >> >> > > > >-- >===================== >Patrick LeBoutillier >Rosemère, Québec, Canada