Skip to content

Metadata fix #1253

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

Merged
merged 5 commits into from
Jan 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ compileJava {
compileJava.outputs.dir("$rootDir/dist/classes")

dependencies {
compile 'org.apache.bcel:bcel:6.0'
compile 'org.apache.bcel:bcel:6.2'
compile files("./src/libs/dx.jar")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import com.telerik.metadata.desc.MethodDescriptor;

import org.apache.bcel.classfile.Attribute;
import org.apache.bcel.classfile.ConstantClass;
import org.apache.bcel.classfile.ConstantPool;
import org.apache.bcel.classfile.ConstantUtf8;
import org.apache.bcel.classfile.Field;
import org.apache.bcel.classfile.InnerClass;
Expand Down Expand Up @@ -36,19 +38,18 @@ private void init() {
return;
}
boolean found = false;
String fullClassName = getClassName(clazz.getClassNameIndex());
if (fullClassName == null) {
return;
}

for (Attribute a : clazz.getAttributes()) {
if (a instanceof InnerClasses) {
InnerClass[] i = ((InnerClasses) a).getInnerClasses();
for (InnerClass ic : i) {
String innerClassName = getClassName(ic.getInnerClassIndex());

ConstantUtf8 cname = (ConstantUtf8) clazz
.getConstantPool().getConstant(ic.getInnerNameIndex());
if (cname == null) {
continue;
}

String innerClassname = cname.getBytes();
if (name.equals(innerClassname)) {
if (fullClassName.equals(innerClassName)) {
int flags = ic.getInnerAccessFlags();
clazz.setAccessFlags(flags);
found = true;
Expand All @@ -63,6 +64,19 @@ private void init() {
}
}

private String getClassName(int classIndex) {
ConstantPool constantPool = clazz.getConstantPool();
ConstantClass innerClassNameIndex = (ConstantClass)constantPool.getConstant(classIndex);
if (innerClassNameIndex == null) {
return null;
}
ConstantUtf8 className = (ConstantUtf8)constantPool.getConstant(innerClassNameIndex.getNameIndex());
if (className == null) {
return null;
}
return className.getBytes();
}

@Override
public boolean isClass() {
return clazz.isClass();
Expand Down