Skip to content

Approximations bugfixes #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public <T> T createInstance(final JcClassOrInterface approx,

List<JcParameter> params = m.getParameters();
if (params.size() != 1) continue;
if (!"java.lang.Object".equals(params.get(0).getType().getTypeName())) continue;

cached_ArrayList_add = m_add = m;
}
Expand All @@ -60,6 +59,16 @@ public <T> T createInstance(final JcClassOrInterface approx,
return decoder.invokeMethod(m_ctor, (List<T>) Collections.EMPTY_LIST);
}

private static List<JcField> getAllFields(JcClassOrInterface clazz) {
JcClassOrInterface superclass = clazz.getSuperClass();
if (superclass == null) {
return clazz.getDeclaredFields();
}
List<JcField> declaredFields = clazz.getDeclaredFields();
declaredFields.addAll(getAllFields(superclass));
return declaredFields;
}

@Override
public <T> void initializeInstance(final JcClassOrInterface approx,
final ObjectData<T> approxData,
Expand All @@ -68,7 +77,7 @@ public <T> void initializeInstance(final JcClassOrInterface approx,
JcField f_storage = cached_ArrayList_storage;
// TODO: add synchronization if needed
if (f_storage == null) {
final List<JcField> fields = approx.getDeclaredFields();
final List<JcField> fields = getAllFields(approx);
for (int i = 0, c = fields.size(); i < c; i++) {
JcField f = fields.get(i);
if ("storage".equals(f.getName())) {
Expand Down
Loading