From 6b86064c33059c6f706db31bdcfbd4444252eaaf Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Fri, 8 Apr 2011 18:04:12 -0700 Subject: [PATCH] Do this in a way that the Java 7 compiler is less angry about. --- .../java/com/samskivert/util/ValueMarshaller.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/samskivert/util/ValueMarshaller.java b/src/main/java/com/samskivert/util/ValueMarshaller.java index 9de7baa3..e5638800 100644 --- a/src/main/java/com/samskivert/util/ValueMarshaller.java +++ b/src/main/java/com/samskivert/util/ValueMarshaller.java @@ -28,11 +28,10 @@ public class ValueMarshaller throws Exception { if (type.isEnum()) { - @SuppressWarnings("unchecked") // we just asked type if it was an enum... - Class etype = (Class)type; - @SuppressWarnings("unchecked") // silly compiler, we're assigning to Object - Object o = Enum.valueOf(etype, source); // may throw an exception - return o; + // we need to use a dummy enum type here as there's no way to ask Enum.valueOf to + // execute on an existentially typed enum; it all works out under the hood + @SuppressWarnings("unchecked") Class etype = (Class)type; + return Enum.valueOf(etype, source); // may throw an exception } // look up an argument parser for the field type Parser parser = _parsers.get(type); @@ -157,4 +156,6 @@ public class ValueMarshaller } }); } + + protected static enum Dummy {}; }