我是靠谱客的博主 激动曲奇,最近开发中收集的这篇文章主要介绍java中madeframe_java字节码中same_frame的含义?,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

An invokespecial instruction is type safe iff all of the following are true:

...

MethodName is .

Descriptor specifies a void return type.

One can validly pop types matching the argument types given in Descriptor and an uninitialized type, UninitializedArg, off the incoming operand stack, yielding OperandStack.

The outgoing type state is derived from the incoming type state by first replacing the incoming operand stack with OperandStack and then replacing all instances of UninitializedArg with the type of instance being initialized.

instructionIsTypeSafe(invokespecial(CP), Environment, _Offset, StackFrame,

NextStackFrame, ExceptionStackFrame) :-

CP = method(MethodClassName, '', Descriptor),

parseMethodDescriptor(Descriptor, OperandArgList, void),

reverse(OperandArgList, StackArgList),

canPop(StackFrame, StackArgList, TempFrame),

TempFrame = frame(Locals, FullOperandStack, Flags),

FullOperandStack = [UninitializedArg | OperandStack],

currentClassLoader(Environment, CurrentLoader),

rewrittenUninitializedType(UninitializedArg, Environment,

class(MethodClassName, CurrentLoader), This),

rewrittenInitializationFlags(UninitializedArg, Flags, NextFlags),

substitute(UninitializedArg, This, OperandStack, NextOperandStack),

substitute(UninitializedArg, This, Locals, NextLocals),

NextStackFrame = frame(NextLocals, NextOperandStack, NextFlags),

ExceptionStackFrame = frame(Locals, [], Flags),

passesProtectedCheck(Environment, MethodClassName, '',

Descriptor, NextStackFrame).

To compute what type the uninitialized argument's type needs to be rewritten to, there are two cases:If we are initializing an object within its constructor, its type is initially uninitializedThis. This type will be rewritten to the type of the class of the method.

The second case arises from initialization of an object created by new. The uninitialized arg type is rewritten to MethodClass, the type of the method holder of . We check whether there really is a new instruction at Address.

rewrittenUninitializedType(uninitializedThis, Environment,

MethodClass, MethodClass) :-

MethodClass = class(MethodClassName, CurrentLoader),

thisClass(Environment, MethodClass).

rewrittenUninitializedType(uninitializedThis, Environment,

MethodClass, MethodClass) :-

MethodClass = class(MethodClassName, CurrentLoader),

thisClass(Environment, class(thisClassName, thisLoader)),

superclassChain(thisClassName, thisLoader, [MethodClass | Rest]).

rewrittenUninitializedType(uninitialized(Address), Environment,

MethodClass, MethodClass) :-

allInstructions(Environment, Instructions),

member(instruction(Address, new(MethodClass)), Instructions).

rewrittenInitializationFlags(uninitializedThis, _Flags, []).

rewrittenInitializationFlags(uninitialized(_), Flags, Flags).

substitute(_Old, _New, [], []).

substitute(Old, New, [Old | FromRest], [New | ToRest]) :-

substitute(Old, New, FromRest, ToRest).

substitute(Old, New, [From1 | FromRest], [From1 | ToRest]) :-

From1 = Old,

substitute(Old, New, FromRest, ToRest).

The rule for invokespecial of an method is the sole motivation for passing back a distinct exception stack frame. The concern is that when initializing an object within its constructor, invokespecial can cause a superclass method to be invoked, and that invocation could fail, leaving this uninitialized. This situation cannot be created using source code in the Java programming language, but can be created by programming in bytecode directly.

In this situation, the original frame holds an uninitialized object in local variable 0 and has flag flagThisUninit. Normal termination of invokespecial initializes the uninitialized object and turns off the flagThisUninit flag. But if the invocation of an method throws an exception, the uninitialized object might be left in a partially initialized state, and needs to be made permanently unusable. This is represented by an exception frame containing the broken object (the new value of the local) and the flagThisUninit flag (the old flag). There is no way to get from an apparently-initialized object bearing theflagThisUninit flag to a properly initialized object, so the object is permanently unusable.

If not for this situation, the flags of the exception stack frame would always be the same as the flags of the input stack frame.

最后

以上就是激动曲奇为你收集整理的java中madeframe_java字节码中same_frame的含义?的全部内容,希望文章能够帮你解决java中madeframe_java字节码中same_frame的含义?所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(43)

评论列表共有 0 条评论

立即
投稿
返回
顶部