• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ByteArray类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.android.dx.util.ByteArray的典型用法代码示例。如果您正苦于以下问题:Java ByteArray类的具体用法?Java ByteArray怎么用?Java ByteArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ByteArray类属于com.android.dx.util包,在下文中一共展示了ByteArray类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: writeTo0

import com.android.dx.util.ByteArray; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void writeTo0(DexFile file, AnnotatedOutput out) {
    ByteArray bytes = value.getBytes();
    int utf16Size = value.getUtf16Size();

    if (out.annotates()) {
        out.annotate(Leb128.unsignedLeb128Size(utf16Size),
                "utf16_size: " + Hex.u4(utf16Size));
        out.annotate(bytes.size() + 1, value.toQuoted());
    }

    out.writeUleb128(utf16Size);
    out.write(bytes);
    out.writeByte(0);
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:17,代码来源:StringDataItem.java


示例2: dump

import com.android.dx.util.ByteArray; //导入依赖的package包/类
/**
 * Does the dumping.
 */
public void dump() {
    byte[] bytes = getBytes();
    ByteArray ba = new ByteArray(bytes);
    DirectClassFile cf =
        new DirectClassFile(ba, getFilePath(), getStrictParse());

    cf.setAttributeFactory(StdAttributeFactory.THE_ONE);
    cf.setObserver(this);
    cf.getMagic(); // Force parsing to happen.

    int at = getAt();
    if (at != bytes.length) {
        parsed(ba, at, bytes.length - at, "<extra data at end of file>");
    }
}
 
开发者ID:johnlee175,项目名称:dex,代码行数:19,代码来源:ClassDumper.java


示例3: DirectClassFile

import com.android.dx.util.ByteArray; //导入依赖的package包/类
/**
 * Constructs an instance.
 *
 * @param bytes {@code non-null;} the bytes of the file
 * @param filePath {@code non-null;} the file path for the class,
 * excluding any base directory specification
 * @param strictParse whether to be strict about parsing; if
 * {@code false}, this avoids doing checks that only exist
 * for purposes of verification (such as magic number matching and
 * path-package consistency checking)
 */
public DirectClassFile(ByteArray bytes, String filePath,
                       boolean strictParse) {
    if (bytes == null) {
        throw new NullPointerException("bytes == null");
    }

    if (filePath == null) {
        throw new NullPointerException("filePath == null");
    }

    this.filePath = filePath;
    this.bytes = bytes;
    this.strictParse = strictParse;
    this.accessFlags = -1;
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:27,代码来源:DirectClassFile.java


示例4: exceptions

import com.android.dx.util.ByteArray; //导入依赖的package包/类
/**
 * Parses an {@code Exceptions} attribute.
 */
private Attribute exceptions(DirectClassFile cf, int offset, int length,
        ParseObserver observer) {
    if (length < 2) {
        return throwSeverelyTruncated();
    }

    ByteArray bytes = cf.getBytes();
    int count = bytes.getUnsignedShort(offset); // number_of_exceptions

    if (observer != null) {
        observer.parsed(bytes, offset, 2,
                        "number_of_exceptions: " + Hex.u2(count));
    }

    offset += 2;
    length -= 2;

    if (length != (count * 2)) {
        throwBadLength((count * 2) + 2);
    }

    TypeList list = cf.makeTypeList(offset, count);
    return new AttExceptions(list);
}
 
开发者ID:johnlee175,项目名称:dex,代码行数:28,代码来源:StdAttributeFactory.java


示例5: constantValue

import com.android.dx.util.ByteArray; //导入依赖的package包/类
/**
 * Parses a {@code ConstantValue} attribute.
 */
private Attribute constantValue(DirectClassFile cf, int offset, int length,
        ParseObserver observer) {
    if (length != 2) {
        return throwBadLength(2);
    }

    ByteArray bytes = cf.getBytes();
    ConstantPool pool = cf.getConstantPool();
    int idx = bytes.getUnsignedShort(offset);
    TypedConstant cst = (TypedConstant) pool.get(idx);
    Attribute result = new AttConstantValue(cst);

    if (observer != null) {
        observer.parsed(bytes, offset, 2, "value: " + cst);
    }

    return result;
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:22,代码来源:StdAttributeFactory.java


示例6: enclosingMethod

import com.android.dx.util.ByteArray; //导入依赖的package包/类
/**
 * Parses an {@code EnclosingMethod} attribute.
 */
private Attribute enclosingMethod(DirectClassFile cf, int offset,
        int length, ParseObserver observer) {
    if (length != 4) {
        throwBadLength(4);
    }

    ByteArray bytes = cf.getBytes();
    ConstantPool pool = cf.getConstantPool();

    int idx = bytes.getUnsignedShort(offset);
    CstType type = (CstType) pool.get(idx);

    idx = bytes.getUnsignedShort(offset + 2);
    CstNat method = (CstNat) pool.get0Ok(idx);

    Attribute result = new AttEnclosingMethod(type, method);

    if (observer != null) {
        observer.parsed(bytes, offset, 2, "class: " + type);
        observer.parsed(bytes, offset + 2, 2, "method: " +
                        DirectClassFile.stringOrNone(method));
    }

    return result;
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:29,代码来源:StdAttributeFactory.java


示例7: sourceFile

import com.android.dx.util.ByteArray; //导入依赖的package包/类
/**
 * Parses a {@code SourceFile} attribute.
 */
private Attribute sourceFile(DirectClassFile cf, int offset, int length,
        ParseObserver observer) {
    if (length != 2) {
        throwBadLength(2);
    }

    ByteArray bytes = cf.getBytes();
    ConstantPool pool = cf.getConstantPool();
    int idx = bytes.getUnsignedShort(offset);
    CstString cst = (CstString) pool.get(idx);
    Attribute result = new AttSourceFile(cst);

    if (observer != null) {
        observer.parsed(bytes, offset, 2, "source: " + cst);
    }

    return result;
}
 
开发者ID:johnlee175,项目名称:dex,代码行数:22,代码来源:StdAttributeFactory.java


示例8: localVariableTable

import com.android.dx.util.ByteArray; //导入依赖的package包/类
/**
 * Parses a {@code LocalVariableTable} attribute.
 */
private Attribute localVariableTable(DirectClassFile cf, int offset,
        int length, ParseObserver observer) {
    if (length < 2) {
        return throwSeverelyTruncated();
    }

    ByteArray bytes = cf.getBytes();
    int count = bytes.getUnsignedShort(offset);

    if (observer != null) {
        observer.parsed(bytes, offset, 2,
                "local_variable_table_length: " + Hex.u2(count));
    }

    LocalVariableList list = parseLocalVariables(
            bytes.slice(offset + 2, offset + length), cf.getConstantPool(),
            observer, count, false);
    return new AttLocalVariableTable(list);
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:23,代码来源:StdAttributeFactory.java


示例9: localVariableTypeTable

import com.android.dx.util.ByteArray; //导入依赖的package包/类
/**
 * Parses a {@code LocalVariableTypeTable} attribute.
 */
private Attribute localVariableTypeTable(DirectClassFile cf, int offset,
        int length, ParseObserver observer) {
    if (length < 2) {
        return throwSeverelyTruncated();
    }

    ByteArray bytes = cf.getBytes();
    int count = bytes.getUnsignedShort(offset);

    if (observer != null) {
        observer.parsed(bytes, offset, 2,
                "local_variable_type_table_length: " + Hex.u2(count));
    }

    LocalVariableList list = parseLocalVariables(
            bytes.slice(offset + 2, offset + length), cf.getConstantPool(),
            observer, count, true);
    return new AttLocalVariableTypeTable(list);
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:23,代码来源:StdAttributeFactory.java


示例10: signature

import com.android.dx.util.ByteArray; //导入依赖的package包/类
/**
 * Parses a {@code Signature} attribute.
 */
private Attribute signature(DirectClassFile cf, int offset, int length,
        ParseObserver observer) {
    if (length != 2) {
        throwBadLength(2);
    }

    ByteArray bytes = cf.getBytes();
    ConstantPool pool = cf.getConstantPool();
    int idx = bytes.getUnsignedShort(offset);
    CstString cst = (CstString) pool.get(idx);
    Attribute result = new AttSignature(cst);

    if (observer != null) {
        observer.parsed(bytes, offset, 2, "signature: " + cst);
    }

    return result;
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:22,代码来源:StdAttributeFactory.java


示例11: dump

import com.android.dx.util.ByteArray; //导入依赖的package包/类
/**
 * Does the dumping.
 */
public void dump() {
    byte[] bytes = getBytes();
    ByteArray ba = new ByteArray(bytes);

    /*
     * First, parse the file completely, so we can safely refer to
     * attributes, etc.
     */
    classFile = new DirectClassFile(ba, getFilePath(), getStrictParse());
    classFile.setAttributeFactory(StdAttributeFactory.THE_ONE);
    classFile.getMagic(); // Force parsing to happen.

    // Next, reparse it and observe the process.
    DirectClassFile liveCf =
        new DirectClassFile(ba, getFilePath(), getStrictParse());
    liveCf.setAttributeFactory(StdAttributeFactory.THE_ONE);
    liveCf.setObserver(this);
    liveCf.getMagic(); // Force parsing to happen.
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:23,代码来源:BlockDumper.java


示例12: endParsingMember

import com.android.dx.util.ByteArray; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void endParsingMember(ByteArray bytes, int offset, String name,
        String descriptor, Member member) {
    if (!(member instanceof Method)) {
        return;
    }

    if (!shouldDumpMethod(name)) {
        return;
    }

    if ((member.getAccessFlags() & (AccessFlags.ACC_ABSTRACT |
            AccessFlags.ACC_NATIVE)) != 0) {
        return;
    }

    ConcreteMethod meth =
        new ConcreteMethod((Method) member, classFile, true, true);

    if (rop) {
        ropDump(meth);
    } else {
        regularDump(meth);
    }
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:27,代码来源:BlockDumper.java


示例13: run

import com.android.dx.util.ByteArray; //导入依赖的package包/类
private void run() {
    ByteArray ba = new ByteArray(bytes);

    /*
     * First, parse the file completely, so we can safely refer to
     * attributes, etc.
     */
    classFile = new DirectClassFile(ba, filePath, strictParse);
    classFile.setAttributeFactory(StdAttributeFactory.THE_ONE);
    classFile.getMagic(); // Force parsing to happen.

    // Next, reparse it and observe the process.
    DirectClassFile liveCf =
        new DirectClassFile(ba, filePath, strictParse);
    liveCf.setAttributeFactory(StdAttributeFactory.THE_ONE);
    liveCf.setObserver(this);
    liveCf.getMagic(); // Force parsing to happen.
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:19,代码来源:DotDumper.java


示例14: writeTo0

import com.android.dx.util.ByteArray; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void writeTo0(DexFile file, AnnotatedOutput out) {
    ByteArray bytes = value.getBytes();
    int utf16Size = value.getUtf16Size();

    if (out.annotates()) {
        out.annotate(Leb128Utils.unsignedLeb128Size(utf16Size),
                "utf16_size: " + Hex.u4(utf16Size));
        out.annotate(bytes.size() + 1, value.toQuoted());
    }

    out.writeUleb128(utf16Size);
    out.write(bytes);
    out.writeByte(0);
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:17,代码来源:StringDataItem.java


示例15: CodeObserver

import com.android.dx.util.ByteArray; //导入依赖的package包/类
/**
 * Constructs an instance.
 *
 * @param bytes {@code non-null;} actual array of bytecode
 * @param observer {@code non-null;} observer to inform of parsing
 */
public CodeObserver(ByteArray bytes, ParseObserver observer) {
    if (bytes == null) {
        throw new NullPointerException("bytes == null");
    }

    if (observer == null) {
        throw new NullPointerException("observer == null");
    }

    this.bytes = bytes;
    this.observer = observer;
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:19,代码来源:CodeObserver.java


示例16: lineNumberTable

import com.android.dx.util.ByteArray; //导入依赖的package包/类
/**
 * Parses a {@code LineNumberTable} attribute.
 */
private Attribute lineNumberTable(DirectClassFile cf, int offset,
        int length, ParseObserver observer) {
    if (length < 2) {
        return throwSeverelyTruncated();
    }

    ByteArray bytes = cf.getBytes();
    int count = bytes.getUnsignedShort(offset); // line_number_table_length

    if (observer != null) {
        observer.parsed(bytes, offset, 2,
                        "line_number_table_length: " + Hex.u2(count));
    }

    offset += 2;
    length -= 2;

    if (length != (count * 4)) {
        throwBadLength((count * 4) + 2);
    }

    LineNumberList list = new LineNumberList(count);

    for (int i = 0; i < count; i++) {
        int startPc = bytes.getUnsignedShort(offset);
        int lineNumber = bytes.getUnsignedShort(offset + 2);
        list.set(i, startPc, lineNumber);
        if (observer != null) {
            observer.parsed(bytes, offset, 4,
                            Hex.u2(startPc) + " " + lineNumber);
        }
        offset += 4;
    }

    list.setImmutable();
    return new AttLineNumberTable(list);
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:41,代码来源:StdAttributeFactory.java


示例17: ConstantPoolParser

import com.android.dx.util.ByteArray; //导入依赖的package包/类
/**
 * Constructs an instance.
 *
 * @param bytes {@code non-null;} the bytes of the file
 */
public ConstantPoolParser(ByteArray bytes) {
    int size = bytes.getUnsignedShort(8); // constant_pool_count

    this.bytes = bytes;
    this.pool = new StdConstantPool(size);
    this.offsets = new int[size];
    this.endOffset = -1;
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:14,代码来源:ConstantPoolParser.java


示例18: parseUtf8

import com.android.dx.util.ByteArray; //导入依赖的package包/类
/**
 * Parses a utf8 constant.
 *
 * @param at offset to the start of the constant (where the tag byte is)
 * @return {@code non-null;} the parsed value
 */
private CstString parseUtf8(int at) {
    int length = bytes.getUnsignedShort(at + 1);

    at += 3; // Skip to the data.

    ByteArray ubytes = bytes.slice(at, at + length);

    try {
        return new CstString(ubytes);
    } catch (IllegalArgumentException ex) {
        // Translate the exception
        throw new ParseException(ex);
    }
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:21,代码来源:ConstantPoolParser.java


示例19: startParsingMember

import com.android.dx.util.ByteArray; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void startParsingMember(ByteArray bytes, int offset, String name,
        String descriptor) {
    if (descriptor.indexOf('(') < 0) {
        // It's a field, not a method
        return;
    }

    if (!shouldDumpMethod(name)) {
        return;
    }

    // Reset the dump cursor to the start of the method.
    setAt(bytes, offset);

    suppressDump = false;

    if (first) {
        first = false;
    } else {
        parsed(bytes, offset, 0, "\n");
    }

    parsed(bytes, offset, 0, "method " + name + " " + descriptor);
    suppressDump = true;
}
 
开发者ID:johnlee175,项目名称:dex,代码行数:28,代码来源:BlockDumper.java


示例20: parsed

import com.android.dx.util.ByteArray; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void parsed(ByteArray bytes, int offset, int len, String human) {
    if (!suppressDump) {
        super.parsed(bytes, offset, len, human);
    }
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:8,代码来源:BlockDumper.java



注:本文中的com.android.dx.util.ByteArray类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GetXAttrsResponseProto类代码示例发布时间:2022-05-22
下一篇:
Java HtmlPanelGrid类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap