Accessing static enum fields with JNI call API
How can we access static fields of an enum using JNI APIs
I am trying to access the glassfish org.glassfish.api.embedded.ContainerBuilder.Type enum from the Glassfish api using the following code
jclass Type= env->FindClass(
"org/glassfish/api/embedded/ContainerBuilder$Type");
jfieldID Type_web=env->GetStaticFieldID(
Type,"web","org/glassfish/api/embedded/ContainerBuilder$Type");
But it always gives me an error like Exception in thread "main" java.lang.NoSuchFieldError: web
how can I access this field?
+2
a source to share
3 answers
Java.lang.Class has getEnumConstants .
According to the doc:
Returns the members of this enumeration class, or null if this class object does not represent an enumeration type.
+2
a source to share