From 9700aa13cdcdfb771c68ce2c742d440e6c176db1 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Wed, 23 Apr 2008 19:58:16 +0000 Subject: [PATCH] Use a method available since JDK1.1 to determine our innerness and simplify the logic. If we're inner and we're not static, we have a problem. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5019 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- src/java/com/threerings/io/Streamer.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/java/com/threerings/io/Streamer.java b/src/java/com/threerings/io/Streamer.java index 239175b93..79c2d78f5 100644 --- a/src/java/com/threerings/io/Streamer.java +++ b/src/java/com/threerings/io/Streamer.java @@ -422,19 +422,15 @@ public class Streamer // keep a handle on the class _target = target; - // if this is a non-anonymous inner class, freak out because we cannot stream those - boolean isLocal = false, isAnon = false, isNSMember = false; - // but don't freak out if we can't find out if this is a non-anonymous inner class; - // production code running on old VMs should be left to do its thing + // if this is a non-static inner class, freak out because we cannot stream those + boolean isInner = false, isStatic = Modifier.isStatic(_target.getModifiers()); try { - isLocal = _target.isLocalClass(); - isAnon = _target.isAnonymousClass(); - isNSMember = _target.isMemberClass() && !Modifier.isStatic(_target.getModifiers()); + isInner = (_target.getDeclaringClass() != null); } catch (Throwable t) { - log.info("Failure checking non-anonymous-innerness of class " + - "[class=" + _target.getName() + ", error=" + t + "]."); + log.info("Failure checking innerness of class [class=" + _target.getName() + + ", error=" + t + "]."); } - if (isLocal || isAnon || isNSMember) { + if (isInner && !isStatic) { throw new IllegalArgumentException( "Cannot stream non-static inner class: " + _target.getName()); }