From dea148de4ff5bf42ff73397888cd36b5be6a9d63 Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Sat, 16 May 2009 18:01:50 +0000 Subject: Fix bug when overriding final void method. Fix bug in generating writeTo/readFrom methods which throw SupportException. --- src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java | 3 +++ src/main/java/com/amazon/carbonado/gen/StorableGenerator.java | 4 ++++ 2 files changed, 7 insertions(+) (limited to 'src/main/java') diff --git a/src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java b/src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java index 3362ad0..f35024e 100644 --- a/src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java +++ b/src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java @@ -311,6 +311,9 @@ public class CodeBuilderUtil { try { Method existing = clazz.getMethod(name, paramClasses); if (Modifier.isFinal(existing.getModifiers())) { + if (retType == null) { + retType = TypeDesc.forClass(void.class); + } if (TypeDesc.forClass(existing.getReturnType()) == retType) { // Method is already implemented and is final. return true; diff --git a/src/main/java/com/amazon/carbonado/gen/StorableGenerator.java b/src/main/java/com/amazon/carbonado/gen/StorableGenerator.java index 4ea40e2..f6a41ca 100644 --- a/src/main/java/com/amazon/carbonado/gen/StorableGenerator.java +++ b/src/main/java/com/amazon/carbonado/gen/StorableGenerator.java @@ -2866,6 +2866,8 @@ public final class StorableGenerator { try { encodedVar = encoder.buildSerialEncoding(b, null); } catch (SupportException e) { + // Wipe out any code generated so far. + b = new CodeBuilder(mi); CodeBuilderUtil.throwException(b, SupportException.class, e.getMessage()); return; } @@ -2914,6 +2916,8 @@ public final class StorableGenerator { try { encoder.buildSerialDecoding(b, null, encodedVar); } catch (SupportException e) { + // Wipe out any code generated so far. + b = new CodeBuilder(mi); CodeBuilderUtil.throwException(b, SupportException.class, e.getMessage()); return; } -- cgit v1.2.3