Skip to content

Commit f718e34

Browse files
Take care of statements like "? extends X" when trying to translate a TypeMirror into a JClass
1 parent ab9642e commit f718e34

3 files changed

Lines changed: 43 additions & 2 deletions

File tree

AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/helper/APTCodeModelHelper.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@
3434
import javax.lang.model.type.ArrayType;
3535
import javax.lang.model.type.DeclaredType;
3636
import javax.lang.model.type.TypeMirror;
37+
import javax.lang.model.type.WildcardType;
3738

3839
import org.androidannotations.processing.EBeanHolder;
3940
import org.androidannotations.processing.EBeansHolder.Classes;
41+
4042
import com.sun.codemodel.JBlock;
4143
import com.sun.codemodel.JCatchBlock;
4244
import com.sun.codemodel.JClass;
@@ -78,6 +80,16 @@ public JClass typeMirrorToJClass(TypeMirror type, EBeanHolder holder) {
7880
}
7981

8082
return declaredClass;
83+
} else if (type instanceof WildcardType) {
84+
// TODO : At his time (01/2013), it is not possible to handle the
85+
// super bound because code model does not offer a way to model
86+
// statement like " ? super X"
87+
// (see http://java.net/jira/browse/CODEMODEL-11)
88+
WildcardType wildcardType = (WildcardType) type;
89+
90+
TypeMirror extendsBound = wildcardType.getExtendsBound();
91+
92+
return typeMirrorToJClass(extendsBound, holder).wildcard();
8193
} else if (type instanceof ArrayType) {
8294
ArrayType arrayType = (ArrayType) type;
8395

AndroidAnnotations/functional-test-1-5/src/main/java/org/androidannotations/test15/ThreadActivity.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,17 @@
1818
import java.util.List;
1919
import java.util.Map;
2020
import java.util.Set;
21-
22-
import android.app.Activity;
21+
import java.util.SortedSet;
2322

2423
import org.androidannotations.annotations.Background;
2524
import org.androidannotations.annotations.EActivity;
2625
import org.androidannotations.annotations.UiThread;
26+
import org.androidannotations.test15.ebean.GenericBean;
27+
import org.androidannotations.test15.ebean.SomeBean;
2728
import org.androidannotations.test15.instancestate.MySerializableBean;
2829

30+
import android.app.Activity;
31+
2932
@EActivity
3033
public class ThreadActivity extends Activity {
3134

@@ -59,6 +62,11 @@ void genericBackgroundMethod(List<Map<String, List<Set<MySerializableBean[]>>>>
5962

6063
}
6164

65+
@Background
66+
void genericBackgroundMethod(Set<? extends GenericBean<? extends SomeBean>> param) {
67+
68+
}
69+
6270
@UiThread(delay = 1000)
6371
void emptyUiDelayedMethod() {
6472

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Copyright (C) 2010-2012 eBusiness Information, Excilys Group
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed To in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
package org.androidannotations.test15.ebean;
17+
18+
19+
public class GenericBean<T> {
20+
21+
}

0 commit comments

Comments
 (0)