Skip to content

fj.data.Java#EnumSet_List throws ClassCastException #33

Description

@cedriessen

Test code

import fj.Show;
import fj.data.Java;
import fj.data.List;

import java.util.EnumSet;

import static fj.Show.listShow;

public class Test {
  public static void main(final String[] args) {
    final List<Colors> colors = Java.<Colors>EnumSet_List().f(EnumSet.allOf(Colors.class));
    listShow(Show.<Colors>anyShow()).print(colors);
  }

  enum Colors {
    red, green, blue
  }
}

Output

Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.Enum;
    at fj.data.Java$77.f(Java.java:1781)
    at fj.data.Java$77.f(Java.java:1778)
    at fj.demo.Test.main(Test.java:13)

The problematic part is this: (A[]) new Object[as.size()]

Many more functions in fj.data.Java use this idiom.

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