// Path: dex-reader-api/src/main/java/com/googlecode/d2j/DexConstants.java
// public abstract interface DexConstants {
// 
//     int ACC_PUBLIC = 0x0001; // class, field, method
//     int ACC_PRIVATE = 0x0002; // class, field, method
//     int ACC_PROTECTED = 0x0004; // class, field, method
//     int ACC_STATIC = 0x0008; // field, method
//     int ACC_FINAL = 0x0010; // class, field, method
//     // int ACC_SUPER = 0x0020; // class
//     int ACC_SYNCHRONIZED = 0x0020; // method
//     int ACC_VOLATILE = 0x0040; // field
//     int ACC_BRIDGE = 0x0040; // method
//     int ACC_VARARGS = 0x0080; // method
//     int ACC_TRANSIENT = 0x0080; // field
//     int ACC_NATIVE = 0x0100; // method
//     int ACC_INTERFACE = 0x0200; // class
//     int ACC_ABSTRACT = 0x0400; // class, method
//     int ACC_STRICT = 0x0800; // method
//     int ACC_SYNTHETIC = 0x1000; // class, field, method
//     int ACC_ANNOTATION = 0x2000; // class
//     int ACC_ENUM = 0x4000; // class(?) field inner
//     int ACC_CONSTRUCTOR = 0x10000;// constructor method (class or instance initializer)
//     int ACC_DECLARED_SYNCHRONIZED = 0x20000;
// 
//     String ANNOTATION_DEFAULT_TYPE = "Ldalvik/annotation/AnnotationDefault;";
//     String ANNOTATION_SIGNATURE_TYPE = "Ldalvik/annotation/Signature;";
//     String ANNOTATION_THROWS_TYPE = "Ldalvik/annotation/Throws;";
//     String ANNOTATION_ENCLOSING_CLASS_TYPE = "Ldalvik/annotation/EnclosingClass;";
//     String ANNOTATION_ENCLOSING_METHOD_TYPE = "Ldalvik/annotation/EnclosingMethod;";
//     String ANNOTATION_INNER_CLASS_TYPE = "Ldalvik/annotation/InnerClass;";
//     String ANNOTATION_MEMBER_CLASSES_TYPE = "Ldalvik/annotation/MemberClasses;";
// 
//     int DEX_035 = 0x00303335;
//     int DEX_036 = 0x00303336;
//     int DEX_037 = 0x00303337;
//     int DEX_038 = 0x00303338;
// }


import java.io.*;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;
import com.googlecode.d2j.*;
import com.googlecode.d2j.node.DexAnnotationNode;
import com.googlecode.d2j.util.Mutf8;
import com.googlecode.d2j.visitors.*;
import static com.googlecode.d2j.DexConstants.*;

                    } catch (Exception e) {
                        throw new DexException(e, "while accept annotation in field:%s.", field.toString());
                    }
                }
            }
            dfv.visitEnd();
        }
        // //////////////////////////////////////////////////////////////
        return field_id;
    }

    private int acceptMethod(ByteBuffer in, int lastIndex, DexClassVisitor cv, Map<Integer, Integer> methodAnnos,
            Map<Integer, Integer> parameterAnnos, int config, boolean firstMethod) {
        int offset = in.position();
        int diff = (int) readULeb128i(in);
        int method_access_flags = (int) readULeb128i(in);
        int code_off = (int) readULeb128i(in);
        int method_id = lastIndex + diff;
        Method method = getMethod(method_id);

        // issue 200, methods may have same signature, we only need to keep the first one
        if (!firstMethod && diff == 0) { // detect a duplicated method
            WARN("GLITCH: duplicated method %s @%08x", method.toString(), offset);
            if ((config & KEEP_ALL_METHODS) == 0) {
                WARN("WARN: skip method %s @%08x", method.toString(), offset);
                return method_id;
            }
        }

        // issue 195, a <clinit> or <init> but not marked as ACC_CONSTRUCTOR,

// Path: dex-reader-api/src/main/java/com/googlecode/d2j/DexConstants.java
// public abstract interface DexConstants {
// 
//     int ACC_PUBLIC = 0x0001; // class, field, method
//     int ACC_PRIVATE = 0x0002; // class, field, method
//     int ACC_PROTECTED = 0x0004; // class, field, method
//     int ACC_STATIC = 0x0008; // field, method
//     int ACC_FINAL = 0x0010; // class, field, method
//     // int ACC_SUPER = 0x0020; // class
//     int ACC_SYNCHRONIZED = 0x0020; // method
//     int ACC_VOLATILE = 0x0040; // field
//     int ACC_BRIDGE = 0x0040; // method
//     int ACC_VARARGS = 0x0080; // method
//     int ACC_TRANSIENT = 0x0080; // field
//     int ACC_NATIVE = 0x0100; // method
//     int ACC_INTERFACE = 0x0200; // class
//     int ACC_ABSTRACT = 0x0400; // class, method
//     int ACC_STRICT = 0x0800; // method
//     int ACC_SYNTHETIC = 0x1000; // class, field, method
//     int ACC_ANNOTATION = 0x2000; // class
//     int ACC_ENUM = 0x4000; // class(?) field inner
//     int ACC_CONSTRUCTOR = 0x10000;// constructor method (class or instance initializer)
//     int ACC_DECLARED_SYNCHRONIZED = 0x20000;
// 
//     String ANNOTATION_DEFAULT_TYPE = "Ldalvik/annotation/AnnotationDefault;";
//     String ANNOTATION_SIGNATURE_TYPE = "Ldalvik/annotation/Signature;";
//     String ANNOTATION_THROWS_TYPE = "Ldalvik/annotation/Throws;";
//     String ANNOTATION_ENCLOSING_CLASS_TYPE = "Ldalvik/annotation/EnclosingClass;";
//     String ANNOTATION_ENCLOSING_METHOD_TYPE = "Ldalvik/annotation/EnclosingMethod;";
//     String ANNOTATION_INNER_CLASS_TYPE = "Ldalvik/annotation/InnerClass;";
//     String ANNOTATION_MEMBER_CLASSES_TYPE = "Ldalvik/annotation/MemberClasses;";
// 
//     int DEX_035 = 0x00303335;
//     int DEX_036 = 0x00303336;
//     int DEX_037 = 0x00303337;
//     int DEX_038 = 0x00303338;
// }


// Path: dex-reader/src/main/java/com/googlecode/d2j/reader/DexFileReader.java
import java.io.*;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;
import com.googlecode.d2j.*;
import com.googlecode.d2j.node.DexAnnotationNode;
import com.googlecode.d2j.util.Mutf8;
import com.googlecode.d2j.visitors.*;
import static com.googlecode.d2j.DexConstants.*;

                    } catch (Exception e) {
                        throw new DexException(e, "while accept annotation in field:%s.", field.toString());
                    }
                }
            }
            dfv.visitEnd();
        }
        // //////////////////////////////////////////////////////////////
        return field_id;
    }

    private int acceptMethod(ByteBuffer in, int lastIndex, DexClassVisitor cv, Map<Integer, Integer> methodAnnos,
            Map<Integer, Integer> parameterAnnos, int config, boolean firstMethod) {
        int offset = in.position();
        int diff = (int) readULeb128i(in);
        int method_access_flags = (int) readULeb128i(in);
        int code_off = (int) readULeb128i(in);
        int method_id = lastIndex + diff;
        Method method = getMethod(method_id);

        // issue 200, methods may have same signature, we only need to keep the first one
        if (!firstMethod && diff == 0) { // detect a duplicated method
            WARN("GLITCH: duplicated method %s @%08x", method.toString(), offset);
            if ((config & KEEP_ALL_METHODS) == 0) {
                WARN("WARN: skip method %s @%08x", method.toString(), offset);
                return method_id;
            }
        }

        // issue 195, a <clinit> or <init> but not marked as ACC_CONSTRUCTOR,

        if (0 == (method_access_flags & DexConstants.ACC_CONSTRUCTOR)
