java子类怎么编译_Java 抽象类的抽象方法子类不重写也能通过编译运行是为什么?...

Classfile /var/workspace/git/trunk/example/metrics-example/target/classes/com/example/metrics/B.class

Last modified 2015-4-27; size 720 bytes

MD5 checksum fcdb010f5173e408131cfcebaada3fdf

Compiled from "ex.java"

class com.example.metrics.B extends com.example.metrics.A

SourceFile: "ex.java"

minor version: 0

major version: 52

flags: ACC_SUPER

Constant pool:

#1 = Class #2 // com/example/metrics/B

#2 = Utf8 com/example/metrics/B

#3 = Class #4 // com/example/metrics/A

#4 = Utf8 com/example/metrics/A

#5 = Utf8

#6 = Utf8 ()V

#7 = Utf8 Code

#8 = Methodref #3.#9 // com/example/metrics/A."":()V

#9 = NameAndType #5:#6 // "":()V

#10 = Utf8 LineNumberTable

#11 = Utf8 LocalVariableTable

#12 = Utf8 this

#13 = Utf8 Lcom/example/metrics/B;

#14 = Utf8 testB

#15 = Fieldref #16.#18 // java/lang/System.out:Ljava/io/PrintStream;

#16 = Class #17 // java/lang/System

#17 = Utf8 java/lang/System

#18 = NameAndType #19:#20 // out:Ljava/io/PrintStream;

#19 = Utf8 out

#20 = Utf8 Ljava/io/PrintStream;

#21 = String #22 // B 继承 A 但是没有重写抽象方法

#22 = Utf8 B 继承 A 但是没有重写抽象方法

#23 = Methodref #24.#26 // java/io/PrintStream.println:(Ljava/lang/String;)V

#24 = Class #25 // java/io/PrintStream

#25 = Utf8 java/io/PrintStream

#26 = NameAndType #27:#28 // println:(Ljava/lang/String;)V

#27 = Utf8 println

#28 = Utf8 (Ljava/lang/String;)V

#29 = Utf8 test

#30 = Class #31 // java/lang/Error

#31 = Utf8 java/lang/Error

#32 = String #33 // Unresolved compilation problem: \n\tThe type B must implement the inherited abstract method A.test()\n

#33 = Utf8 Unresolved compilation problem: \n\tThe type B must implement the inherited abstract method A.test()\n

#34 = Methodref #30.#35 // java/lang/Error."":(Ljava/lang/String;)V

#35 = NameAndType #5:#28 // "":(Ljava/lang/String;)V

#36 = Utf8 SourceFile

#37 = Utf8 ex.java

{

com.example.metrics.B();

flags:

Code:

stack=1, locals=1, args_size=1

0: aload_0

1: invokespecial #8 // Method com/example/metrics/A."":()V

4: return

LineNumberTable:

line 11: 0

LocalVariableTable:

Start Length Slot Name Signature

0 5 0 this Lcom/example/metrics/B;

public void testB();

flags: ACC_PUBLIC

Code:

stack=2, locals=1, args_size=1

0: getstatic #15 // Field java/lang/System.out:Ljava/io/PrintStream;

3: ldc #21 // String B 继承 A 但是没有重写抽象方法

5: invokevirtual #23 // Method java/io/PrintStream.println:(Ljava/lang/String;)V

8: return

LineNumberTable:

line 13: 0

line 14: 8

LocalVariableTable:

Start Length Slot Name Signature

0 9 0 this Lcom/example/metrics/B;

void test();

flags: ACC_SYNTHETIC

Code:

stack=3, locals=1, args_size=1

0: new #30 // class java/lang/Error

3: dup

4: ldc #32 // String Unresolved compilation problem: \n\tThe type B must implement the inherited abstract method A.test()\n

6: invokespecial #34 // Method java/lang/Error."":(Ljava/lang/String;)V

9: athrow

LineNumberTable:

line 11: 0

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值