Enumset reflection problem

Hi All,

I faced with a problem over a week and I hope somone has a solution for that.

I have enum like this:

package com.lo.enums;

public enum Tag{

Tag1,

Tag2,

Tag3

}

I have tried to create dynamically using reflection EnumSet of that enum but getting always java.lang.ClassNotFoundException exception.

I have tried to do like this:

String type = "java.util.EnumSet<com.lo.enums.Tag>";

Class clazz = Class.forName(type);

Thanks for the help.

[533 byte] By [shaharwra] at [2007-11-27 3:28:09]
# 1

There is no class named "java.util.EnumSet<com.lo.enums.Tag>". You cannot reflectively create parameterized classes. Furthermore, EnumSet is an abstract class, providing static factories to create Sets on Enums. So you may get the EnumSet class and one of the needed static methods by reflection and invoke it passing the according enum class.

stefan.schulza at 2007-7-12 8:30:57 > top of Java-index,Core,Core APIs...