Skip to content

Unable to find methods inside enum constants #131

Open
@rahlk

Description

@rahlk

Describe the bug
I'm trying to find and invoke methods that are defined within individual enum constants, but I'm unable to locate these methods.

To Reproduce
Steps to reproduce the behavior:

  1. Try to access methods defined in the enum constants

Example code with ToNumberPolicy enum implementing ToNumberStrategy:

public interface ToNumberStrategy {
  public Number readNumber(JsonReader in) throws IOException;
}

public enum ToNumberPolicy implements ToNumberStrategy {
  DOUBLE {
    @Override
    public Double readNumber(JsonReader in) throws IOException {
      return in.nextDouble();
    }
  },
  
  LAZILY_PARSED_NUMBER {
    @Override
    public Number readNumber(JsonReader in) throws IOException {
      return new LazilyParsedNumber(in.nextString());
    }
  },
  
  // Other enum constants with their own implementations...
}

Expected behavior
I expect to be able to find the readNumber method for each enum constant via reflection, as each constant has its own implementation of the method.

Additional context
The issue appears to be that each enum constant is actually an anonymous inner class of ToNumberPolicy.
However, I need to access these methods with codeanalyzer.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions