java getgenericinterfaces_java – Class#getInterfaces()和Class#getGenericInterfaces()返回不同长度的数组...

// Compiled from AbstractPartialFunction.scala (version 1.6 : 50.0, super bit)

// Signature: Ljava/lang/Object;Lscala/Function1;Lscala/PartialFunction;

@scala.reflect.ScalaSignature(bytes="some bytes...")

public abstract class scala.runtime.AbstractPartialFunction implements scala.PartialFunction {

该类型的签名大致相当于此Java声明:

class AbstractPartialFunction implements PartialFunction, Function1 {}

PartialFunction扩展了Function1:

// Compiled from PartialFunction.scala (version 1.6 : 50.0, no super bit)

// Signature: Ljava/lang/Object;Lscala/Function1;

@scala.reflect.ScalaSignature(bytes="some bytes...")

public abstract interface scala.PartialFunction extends scala.Function1 {

ClassFile {

u4 magic;

u2 minor_version;

u2 major_version;

u2 constant_pool_count;

cp_info constant_pool[constant_pool_count-1];

u2 access_flags;

u2 this_class;

u2 super_class;

u2 interfaces_count;

u2 interfaces[interfaces_count];

u2 fields_count;

field_info fields[fields_count];

u2 methods_count;

method_info methods[methods_count];

u2 attributes_count;

attribute_info attributes[attributes_count];

}

类型实现的接口存储在常量池中,并由interfaces数组中的引用记录:

The Signature attribute records generic signature information for any class, interface, constructor or member whose generic signature in the Java programming language would include references to type variables or parameterized types.

所以这是我对所发生事情的有根据的猜测:

> Class.getInterfaces()返回interfaces数组中的值

> Class.getGenericInterfaces()使用类型签名构建其返回值

> Scala编译器从interfaces数组中删除Function1,因为PartialFunction扩展了Function1

> Scala编译器按原样保留类型签名

此行为与Oracle JDK从等效Java源生成的字节代码不同,但显然是在传递JVM加载类时所做的所有检查.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值