Do this in a way that the Java 7 compiler is less angry about.
This commit is contained in:
@@ -28,11 +28,10 @@ public class ValueMarshaller
|
|||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
if (type.isEnum()) {
|
if (type.isEnum()) {
|
||||||
@SuppressWarnings("unchecked") // we just asked type if it was an enum...
|
// we need to use a dummy enum type here as there's no way to ask Enum.valueOf to
|
||||||
Class<? extends Enum> etype = (Class<? extends Enum>)type;
|
// execute on an existentially typed enum; it all works out under the hood
|
||||||
@SuppressWarnings("unchecked") // silly compiler, we're assigning to Object
|
@SuppressWarnings("unchecked") Class<Dummy> etype = (Class<Dummy>)type;
|
||||||
Object o = Enum.valueOf(etype, source); // may throw an exception
|
return Enum.valueOf(etype, source); // may throw an exception
|
||||||
return o;
|
|
||||||
}
|
}
|
||||||
// look up an argument parser for the field type
|
// look up an argument parser for the field type
|
||||||
Parser parser = _parsers.get(type);
|
Parser parser = _parsers.get(type);
|
||||||
@@ -157,4 +156,6 @@ public class ValueMarshaller
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static enum Dummy {};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user