-
Hey, we want to access the enums in this class: https://tinkerpop.apache.org/javadocs/current/core/org/apache/tinkerpop/gremlin/structure/VertexProperty.Cardinality.html from within JRuby. How to distinguish between static enum and static method? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Just to be clear, this happened when you upgraded the gremlin jar, yes? This is a tricky one; given that they have methods and enum values with the same way, I'm not sure how we can represent both at the same time in JRuby. I'll try to loop in some other JRuby folks to discuss. |
Beta Was this translation helpful? Give feedback.
-
Minimized example: public enum A {
one,
two,
three,
Four;
public static void Four(int i) {}
public static void one(int i) {}
} CLASSPATH=. jruby -I. -e 'p Java::A::const_get(:one)' # boom (lowercase...boooooo) but CLASSPATH=. jruby -I. -e 'p Java::A::const_get(:Four)' # yay So I think for JavaClasses we relax const_get to allow non-capitalized forms would fix this but also require a little metaprogramming. I think this is ok in this case as it is atypical to use non-const enum values AND happen to have a static method with the same name. |
Beta Was this translation helpful? Give feedback.
-
I've filed a bug for this in #8188. A workaround for you for now would be to use reflection to access the enum values:
You should be able to take this further and define Ruby capitalized constants for those values, and just use the constants in your code. |
Beta Was this translation helpful? Give feedback.
I've filed a bug for this in #8188.
A workaround for you for now would be to use reflection to access the enum values:
You should be able to take this further and define Ruby capitalized constants for those values, and just use the constants in your code.