ffutop

ASM-VerifyError错误信息解决

2018-06-28

报错信息

java.lang.VerifyError: class net.sf.cglib.core.DebuggingClassWriter overrides final method visit.(IILjava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)V

阅读更多


ASM 核心包基本内容漫谈

2018-06-25

本文描述的 ASM 指的是 OW2 ASM

ASM-Core 的结构

首先是一些概述性的内容。

由于 ASM 操作的 JAVA 字节码有严格的格式规定,且即使随着 JVM 标准的升级也极少出现重大调整。 因此适用面狭窄的访问者模式在该项目中被大量地使用,并且已经到了丧心病狂的程度:)

从核心包声明的类来看,主要包括:

  1. ClassReader - 作为结构化对象,将接收(accept)访问者的访问

  2. 几种访问者抽象类以及相应的实现类

  • AnnotationVisitor -> AnnotationWriter
  • ClassVisitor -> ClassWriter
  • FieldVisitor -> FieldWriter
  • MethodVisitor -> MethodWriter
  • ModuleVisitor -> ModuleWriter
  1. Opcodes & Constants - ClassFile 中描述的大量常量符号与值

  2. 其它一些辅助的类

  • Attribute - 用于处理非标准化的属性(ClassFile 允许JVMS 中未定义的 Attribute)
  • ByteArray - 动态可自适应的 byte[] (字节数组)
  • Context - ClassReader 在被解析(被访问)过程中用于表示“累积状态”的一个类/对象
  • Symbol - 用于表示 ClassFile 中描述的 Constant 的基类
  • SymbolTable - 用于存储常量池对象
  • 其它内容省略

阅读更多


java-memory-model

2018-06-21

JVM 运行时数据区

阅读更多


ASM - ClassReader 与 Java ClassFile 文件格式

2018-06-11

Java ClassFile 文件格式

读了将近一周的时间,勉强算是把 ClassFile 的文件格式给简单的梳理了个脉络。 The class File Format(Java SE 8)

u1, u2, u4 分别表示无符号的一字节、二字节、四字节数据(以大端存储)

ClassFile {
    u4             magic;                                   // 魔数(magic) 固定为 0xCAFEBABE
    u2             minor_version;                           // 次版本号
    u2             major_version;                           // 主版本号
    u2             constant_pool_count;                     // 常量池 constant_pool 的数量 + 1, 最大为 (2<<16 - 1) = 65535
    cp_info        constant_pool[constant_pool_count-1];    // 常量池 取值下标为 [1, constant_pool_count)
    u2             access_flags;                            // 对类 or 接口的访问权限和属性的标志的掩码
    u2             this_class;                              // 值为 constant_pool 的有效下标(且 constant_pool[this_class] 的类型为 CONSTANT_Class_info)
    u2             super_class;                             // 值为 0 或者 constant_pool 的有效下标(同上), 如果是 interface, 则该值一定为有效下标
    u2             interfaces_count;                        // 直接父接口的数量
    u2             interfaces[interfaces_count];            // 值必须是 constant_pool 的有效下标, 且 interfaces[i](0≤i<interfaces_count), 指向的类型为 CONSTANT_Class_info)
    u2             fields_count;                            // 字段数量, 统计所有字段, 包括 class variables(静态变量) 和 instance variables(实例变量)
    field_info     fields[fields_count];                    // 字段的详细声明, 不包含继承来的字段
    u2             methods_count;                           // 方法数量
    method_info    methods[methods_count];                  // 方法的详细声明, 不包括继承来的方法
    u2             attributes_count;                        // 属性数量
    attribute_info attributes[attributes_count];            // 属性的详细声明
}

阅读更多


区块链技术概述

2018-03-01

区块链简单结构

Merkle tree

阅读更多


Spring JDBC 源码学习

2018-01-15

概览

在学习 Spring-JDBC 之前,我们有必要从 Java 原生提供的 JDBC 开始,对 JDBC 操作的一整套完整的流程有一个清晰的概念。

阅读更多