Skip to content

Commit

Permalink
minor tweaking of #30 fix to future-proof wr jackson 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Sep 15, 2017
1 parent efc8118 commit 485730c
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.fasterxml.jackson.module.afterburner.deser.java8;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.module.afterburner.AfterburnerTestBase;

// for [modules-base#30]
public class DefaultMethodsTest extends AfterburnerTestBase
{
// NOTE: can only be enabled for Jackson 3.x
/*
public interface Typed {
default String getType() {
return "bogus";
}
default void setType(String type) { internalSet(type); }
void internalSet(String s);
}
static class Model implements Typed {
String x;
@Override
public void internalSet(String value) {
x = value;
}
}
*/

// for Jackson 2.x:
public interface Typed {
public String getType();
public void setType(String t);
}

static class Model implements Typed {
String x;

@Override
public String getType() { return "bogus"; }
@Override
public void setType(String t) { x = t; }
}

/*
/**********************************************************************
/* Test methods
/**********************************************************************
*/

private final ObjectMapper MAPPER = newObjectMapper();

public void testSerializeViaDefault() throws Exception
{
assertEquals(aposToQuotes("{'type':'bogus'}"),
MAPPER.writeValueAsString(new Model()));
}

public void testDeserializeViaDefault() throws Exception
{
// Would throws `java.lang.IncompatibleClassChangeError`
Model m = MAPPER.readValue(aposToQuotes("{'type':'stuff'}"),
Model.class);
assertNotNull(m);
assertEquals("stuff", m.x);
}
}
12 changes: 6 additions & 6 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ Modules:
=== Releases ===
------------------------------------------------------------------------

2.9.2 (not yet released)

#30: (afterburner) `IncompatibleClassChangeError` deserializing interface
methods with default impl
(reported by Shawn S)

2.9.1 (07-Sep-2017)

No changes since 2.9.0
Expand All @@ -18,12 +24,6 @@ No changes since 2.9.0
indirecton (simpler code, potential minor performance improvement)
- Add `jackson-module-jaxb-annotations` as one more base module!

2.8.11 (not yet released)

#30: (afterburner) `IncompatibleClassChangeError` deserializing interface
methods with default impl
(reported by Shawn S)

2.8.10 (24-Aug-2017)
2.8.9 (12-Jun-2017)
2.8.8 (05-Apr-2017)
Expand Down

0 comments on commit 485730c

Please sign in to comment.