File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed
main/java/org/msgpack/template
test/java/org/msgpack/template Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -342,6 +342,11 @@ private <T> Template<T> lookupSuperclasses(Class<T> targetClass) {
342342 if (tmpl != null ) {
343343 register (targetClass , tmpl );
344344 return tmpl ;
345+ } else {
346+ tmpl = (Template <T >) lookupInterfaceTypes (superClass );
347+ if (tmpl != null ) {
348+ return tmpl ;
349+ }
345350 }
346351 } catch (NullPointerException e ) { // ignore
347352 }
Original file line number Diff line number Diff line change 1+ package org .msgpack .template ;
2+
3+ import static org .hamcrest .CoreMatchers .*;
4+ import static org .junit .Assert .*;
5+
6+ import java .util .ArrayList ;
7+ import java .util .Arrays ;
8+ import java .util .List ;
9+
10+ import org .junit .Test ;
11+
12+ public class TestTemplateRegistry {
13+
14+ private static final TemplateRegistry root = new TemplateRegistry (null );
15+
16+ static class MyArrayList <E > extends ArrayList <E > {
17+ private static final long serialVersionUID = 1L ;
18+ }
19+
20+ @ Test
21+ public void testTraverseInterface () throws Exception {
22+ Template <?> template = root .lookup (List .class );
23+ assertThat (template , is (instanceOf (ListTemplate .class )));
24+ }
25+
26+ @ Test
27+ public void testTraverseDescentInterface () throws Exception {
28+ Template <?> template = root .lookup (MyArrayList .class );
29+ assertThat (template , is (instanceOf (ListTemplate .class )));
30+ }
31+
32+ @ Test
33+ public void testArraysAsListIsPackable () throws Exception {
34+ Template <?> template = root .lookup (Arrays .asList ().getClass ());
35+ assertThat (template , is (instanceOf (ListTemplate .class )));
36+ }
37+
38+ }
You can’t perform that action at this time.
0 commit comments