GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Support for Java enums in Native Types · Issue #1077 · cel-expr/cel-java

Support for Java enums in Native Types #1077

New issue
Copy link
New issue
Copy link
Open
Open
Support for Java enums in Native Types#1077
Copy link

Description

@dteleguin
dteleguin
opened on Jun 3, 2026
Issue body actions

Imagine a class with an enum property:

public class Foo {

    private Bar bar;

    public Bar getBar() {
        return bar;
    }

    public void setBar(Bar bar) {
        this.bar = bar;
    }

}

public enum Bar {
    FOO,
    BAR
}

Registering such a class with Native Types results in an exception:

Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.IllegalArgumentException: Unsupported type for property 'typeParameters' in class java.lang.Class
	at dev.cel.extensions.CelNativeTypesExtensions$NativeTypeScanner.validateRegisteredClasses(CelNativeTypesExtensions.java:236)
	at dev.cel.extensions.CelNativeTypesExtensions$NativeTypeScanner.scan(CelNativeTypesExtensions.java:221)
	at dev.cel.extensions.CelNativeTypesExtensions$NativeTypeScanner.access$000(CelNativeTypesExtensions.java:154)
	at dev.cel.extensions.CelNativeTypesExtensions.nativeTypes(CelNativeTypesExtensions.java:131)
	at dev.cel.extensions.CelExtensions.nativeTypes(CelExtensions.java:362)
	at CELTest.<clinit>(CELTest.java:40)
Caused by: java.lang.IllegalArgumentException: Unsupported interface type: java.lang.reflect.TypeVariable
	at dev.cel.extensions.CelNativeTypesExtensions$NativeTypeScanner.mapJavaTypeToCelType(CelNativeTypesExtensions.java:302)
	at dev.cel.extensions.CelNativeTypesExtensions$NativeTypeScanner.mapJavaTypeToCelType(CelNativeTypesExtensions.java:296)
	at dev.cel.extensions.CelNativeTypesExtensions$NativeTypeScanner.getPropertyType(CelNativeTypesExtensions.java:276)
	at dev.cel.extensions.CelNativeTypesExtensions$NativeTypeScanner.validateRegisteredClasses(CelNativeTypesExtensions.java:233)
	... 5 more

This happens because CEL tries to introspect the implicit declaringClass property of the Java enum (which resolves to java.lang.Class, which has an interface-typed property typeParameters, which is not supported because of #1061). Perhaps we need to blacklist the standard java.lang.Enum methods the same way we do for java.lang.Object.

Activity

  1. dteleguin
    changed the title [-]Support Java enums in Native Types[/-] [+]Support for Java enums in Native Types[/+] on Jun 4, 2026
  2. copybara-service
    added 4 commits that reference this issue on Jun 5, 2026

    Safely ignore enums in native type extensions

    4e58e12

    Safely ignore enums in native type extensions

    6369ccf

    Safely ignore enums in native type extensions

    03d6a74

    Safely ignore enums in native type extensions

    49851f5
  3. l46kok commented on Jun 5, 2026

    @l46kok
    l46kok
    on Jun 5, 2026
    Collaborator
    More actions

    We'll safely exclude enums from the bindings for now and update the documentation accordingly. Supporting them properly requires a larger architectural decision on the underlying type i.e: ints for Protobuf parity (via ordinals or a custom interface) against exposing them as strings, which is more commonly seen in other Java serialization ecosystems.

  4. dteleguin commented on Jun 6, 2026

    @dteleguin
    dteleguin
    on Jun 6, 2026
    Author
    More actions

    I can confirm that with both #1078 and #1069 I have been able to bind JsonWebToken and evaluate expressions on it. Great job!

    However, we should not underestimate the importance of Enums; in the said JsonWebToken, the category property is modeled as an enum, and I could imagine it being used inside a policy (e.g. to implement different rules for different token types).

    Another prominent example in Keycloak is EventType. This one is also interesting because it assumes the possibility of numeric comparison between the enum members - this is how you can select entire event type category. (In EventType, there is a special stableIndex property for that, but I could imagine a case where plain ordinals might be used).

    Therefore, I would suggest to model enums as ordinals (or at least to keep the ordinals internally to enable comparison).

  5. copybara-service
    added 2 commits that reference this issue on Jun 9, 2026

    Safely ignore enums in native type extensions

    3ab3014

    Safely ignore enums in native type extensions

    02052f3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.