/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/** This class provides operations to map an internal symbol table graph
* rooted in a ClassSymbol into a classfile.
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own risk.
* This code and its internal interfaces are subject to change or
* deletion without notice.</b>
*/
/** Switch: verbose output.
*/
private boolean verbose;
/** Switch: scrable private names.
*/
private boolean scramble;
/** Switch: scrable private names.
*/
private boolean scrambleAll;
/** Switch: retrofit mode.
*/
private boolean retrofit;
/** Switch: emit source file attribute.
*/
private boolean emitSourceFile;
/** Switch: generate CharacterRangeTable attribute.
*/
private boolean genCrt;
/** Switch: describe the generated stackmap
*/
boolean debugstackmap;
/**
* Target class version.
*/
/**
* Source language version.
*/
/** Type utilities. */
/** The initial sizes of the data and constant pool buffers.
* sizes are increased when buffers get full.
*/
/** An output buffer for member info.
*/
/** An output buffer for the constant pool.
*/
/** An output buffer for type signatures.
*/
/** The constant pool.
*/
/** The inner classes to be written, as a set.
*/
/** The inner classes to be written, as a queue where
* enclosing classes come first.
*/
/** The log to use for verbose output.
*/
/** The name table. */
/** Access to files. */
/** The tags and constants used in compressed stackmap. */
/** Get the ClassWriter instance for this context. */
return instance;
}
/** Construct a class writer, given an options table.
*/
}
/******************************************************************
* Diagnostics: dump generated class names and modifiers
******************************************************************/
/** Value of option 'dumpmodifiers' is a string
* indicating which modifiers should be dumped for debugging:
* 'c' -- classes
* 'f' -- fields
* 'i' -- innerclass attributes
* 'm' -- methods
* For example, to dump everything:
* javac -XDdumpmodifiers=cifm MyProg.java
*/
/** Return flags as a string, separated by " ".
*/
int i = 0;
long f = flags & StandardFlags;
while (f != 0) {
if ((f & 1) != 0) {
}
f = f >> 1;
i++;
}
}
//where
"PUBLIC", "PRIVATE", "PROTECTED", "STATIC", "FINAL",
"SUPER", "VOLATILE", "TRANSIENT", "NATIVE", "INTERFACE",
"ABSTRACT", "STRICTFP"};
/******************************************************************
* Output routines
******************************************************************/
/** Write a character into given byte buffer;
* byte buffer will not be grown.
*/
}
/** Write an integer into given byte buffer;
* byte buffer will not be grown.
*/
}
/******************************************************************
* Signature Generation
******************************************************************/
/** Assemble signature of given type in string buffer.
*/
case BYTE:
break;
case SHORT:
break;
case CHAR:
break;
case INT:
break;
case LONG:
break;
case FLOAT:
break;
case DOUBLE:
break;
case BOOLEAN:
break;
case VOID:
break;
case CLASS:
break;
case ARRAY:
break;
case METHOD:
assembleSig(l.head);
}
}
break;
case WILDCARD: {
case SUPER:
break;
case EXTENDS:
break;
case UNBOUND:
break;
default:
}
break;
}
case TYPEVAR:
break;
case FORALL:
break;
case UNINITIALIZED_THIS:
case UNINITIALIZED_OBJECT:
// we don't yet have a spec for uninitialized types in the
// local variable table
break;
default:
}
}
while (l.nonEmpty()) {
l = l.tail;
}
return false;
}
enterInner(c);
boolean rawOuter =
: outer);
: c.name);
} else {
}
}
}
}
}
assembleSig(l.head);
}
}
}
/** Return signature of given type
*/
//- System.out.println(" ? " + type);
//- System.out.println(" " + n);
return n;
}
/** Given a type t, return the extended class name of its erasure in
* external representation.
*/
} else {
throw new AssertionError("xClassName");
}
}
/******************************************************************
* Writing the Constant Pool
******************************************************************/
/** Thrown when the constant pool is over full.
*/
public PoolOverflow() {}
}
value = s;
}
}
/** Write constant pool to pool buffer.
* Note: during writing, constant pool
* might grow since some parts of constants still need to be entered.
*/
int i = 1;
if (value instanceof MethodSymbol) {
} else if (value instanceof ClassSymbol) {
} else {
enterInner(c);
}
} else if (value instanceof NameAndType) {
i++;
i++;
} else {
}
i++;
}
throw new PoolOverflow();
}
/** Given a field, return its name.
*/
else
}
/** Given a symbol, return its name-and-type.
*/
// if we retrofit, then the NameAndType has been read in as is
// and no change is necessary. If we compile normally, the
// NameAndType is generated from a symbol reference, and the
// adjustment of adding an additional this$n parameter needs to be made.
}
/******************************************************************
* Writing Attributes
******************************************************************/
/** Write header for an attribute to data buffer and return
* position past attribute length index.
*/
}
/** Fill in attribute length.
*/
}
/** Leave space for attribute count and return index for
* number of attributes field.
*/
int beginAttrs() {
}
/** Fill in number of attributes.
*/
}
/** Write the EnclosingMethod attribute if needed.
* Returns the number of attributes written (0 or 1).
*/
if (!target.hasEnclosingMethodAttribute() ||
return 0;
? null
: (MethodSymbol)c.owner;
return 1;
}
/** Write flag attributes; return number of attributes written.
*/
int acount = 0;
acount++;
}
acount++;
}
acount++;
}
acount++;
}
acount++;
}
acount++;
}
return acount;
}
/** Write member (field or method) attributes;
* return number of attributes written.
*/
if (source.allowGenerics() &&
// note that a local class with captured variables
// will get a signature attribute
acount++;
}
return acount;
}
/** Write method parameter annotations;
* return number of attributes written.
*/
boolean hasVisible = false;
boolean hasInvisible = false;
switch (types.getRetention(a)) {
case SOURCE: break;
case CLASS: hasInvisible = true; break;
case RUNTIME: hasVisible = true; break;
default: ;// /* fail soft */ throw new AssertionError(vis);
}
}
}
int attrCount = 0;
if (hasVisible) {
}
attrCount++;
}
if (hasInvisible) {
}
attrCount++;
}
return attrCount;
}
/**********************************************************************
* Writing Java-language annotations (aka metadata, attributes)
**********************************************************************/
/** Write Java-language annotations; return number of JVM
* attributes written (zero or one).
*/
switch (types.getRetention(a)) {
case SOURCE: break;
default: ;// /* fail soft */ throw new AssertionError(vis);
}
}
int attrCount = 0;
attrCount++;
}
attrCount++;
}
return attrCount;
}
/** A visitor to write an attribute including its leading
* single-character marker.
*/
case BYTE:
break;
case CHAR:
break;
case SHORT:
break;
case INT:
break;
case LONG:
break;
case FLOAT:
break;
case DOUBLE:
break;
case BOOLEAN:
break;
case CLASS:
break;
default:
}
}
}
}
}
throw new AssertionError(x);
}
a.accept(this);
}
}
}
/** Write a compound attribute excluding the '@' marker. */
}
}
/**********************************************************************
* Writing Objects
**********************************************************************/
*/
if (c.type.isCompound()) {
}
try {
c.complete();
} catch (CompletionFailure ex) {
throw ex;
}
// log.errWriter.println("enter inner " + c);//DEBUG
if (innerClasses == null) {
}
innerClasses.add(c);
}
}
/** Write "inner classes" attribute.
*/
void writeInnerClasses() {
l.nonEmpty();
l = l.tail) {
if (dumpInnerClassModifiers) {
}
}
}
/** Write field symbol, entering all references into constant pool.
*/
if (dumpFieldModifiers) {
}
int acountIdx = beginAttrs();
int acount = 0;
if (v.getConstValue() != null) {
acount++;
}
acount += writeMemberAttrs(v);
}
/** Write method symbol, entering all references into constant pool.
*/
if (dumpMethodModifiers) {
}
int acountIdx = beginAttrs();
int acount = 0;
acount++;
}
acount++;
}
if (m.defaultValue != null) {
acount++;
}
acount += writeMemberAttrs(m);
acount += writeParameterAttrs(m);
}
/** Write code attribute of method.
*/
l.nonEmpty();
l = l.tail) {
}
int acountIdx = beginAttrs();
int acount = 0;
l.nonEmpty();
l = l.tail)
acount++;
}
int crtIdx = beginAttrs();
acount++;
}
// counter for number of generic local variables
int nGenericVars = 0;
// write variable info
nGenericVars++;
}
acount++;
}
if (nGenericVars > 0) {
int count = 0;
continue;
count++;
// write variable info
}
acount++;
}
acount++;
}
}
//where
//a local variable needs a type-entry if its type T is generic
//(i.e. |T| != T) and if it's not an intersection type (not supported
//in signature attribute grammar)
!t.isCompound());
}
case CLDC:
for (int i=0; i<nframes; i++) {
// output PC
// output locals
int localCount = 0;
localCount++;
}
}
// output stack
int stackCount = 0;
stackCount++;
}
}
}
break;
case JSR202: {
for (int i=0; i<nframes; i++) {
}
break;
}
default:
throw new AssertionError("Unexpected stackmap format value");
}
}
//where
if (t == null) {
}
else switch(t.tag) {
case BYTE:
case CHAR:
case SHORT:
case INT:
case BOOLEAN:
break;
case FLOAT:
break;
case DOUBLE:
break;
case LONG:
break;
case BOT: // null
break;
case CLASS:
case ARRAY:
break;
case TYPEVAR:
break;
case UNINITIALIZED_THIS:
break;
case UNINITIALIZED_OBJECT:
}
break;
default:
throw new AssertionError();
}
}
/** An entry in the JSR202 StackMapTable */
abstract static class StackMapTableFrame {
abstract int getFrameType();
int frameType = getFrameType();
}
final int offsetDelta;
this.offsetDelta = offsetDelta;
}
int getFrameType() {
}
if (getFrameType() == SAME_FRAME_EXTENDED) {
if (writer.debugstackmap){
}
}
}
}
final int offsetDelta;
this.offsetDelta = offsetDelta;
}
int getFrameType() {
return (offsetDelta < SAME_FRAME_SIZE) ?
(SAME_FRAME_SIZE + offsetDelta) :
}
if (getFrameType() == SAME_LOCALS_1_STACK_ITEM_EXTENDED) {
if (writer.debugstackmap) {
}
}
if (writer.debugstackmap) {
}
}
}
final int frameType;
final int offsetDelta;
this.offsetDelta = offsetDelta;
}
if (writer.debugstackmap) {
}
}
}
final int frameType;
final int offsetDelta;
this.offsetDelta = offsetDelta;
}
if (writer.debugstackmap) {
}
}
}
}
final int offsetDelta;
this.offsetDelta = offsetDelta;
}
if (writer.debugstackmap) {
}
}
}
}
}
/** Compare this frame with the previous frame and produce
* an entry of compressed stack map frame. */
int prev_pc,
Type[] prev_locals,
}
if (diff_length == 0) {
return new SameFrame(offset_delta);
// APPEND
local_diff[j] = locals[i];
}
// CHOP
}
}
// FULL_FRAME
}
}
} else {
return false;
}
return false;
}
}
}
for (int i=0; i<len; i++) {
}
}
return diff_length;
}
}
// process them in reverse sibling order;
// i.e., process them in declaration order.
}
}
}
}
}
}
/** Emit a class file for a given class.
* @param c The class from which a class file is generated.
*/
{
c.sourcefile);
try {
writeClassFile(out, c);
if (verbose)
} finally {
// if we are propogating an exception, delete the file
}
}
return outFile; // may be null if write failed
}
/** Write class `c' to outstream `out'.
*/
innerClasses = null;
if (dumpClassModifiers) {
}
int fieldsCount = 0;
int methodsCount = 0;
case VAR: fieldsCount++; break;
break;
}
}
if (c.trans_local != null) {
}
}
int acountIdx = beginAttrs();
int acount = 0;
boolean sigReq =
if (sigReq) {
assembleSig(l.head);
acount++;
}
// WHM 6/29/1999: Strip file path prefix. We do it here at
// the last possible moment because the sourcefile may be used
// elsewhere in error diagnostics. Fixes 4241573.
//databuf.appendChar(c.pool.put(c.sourcefile));
acount++;
}
if (genCrt) {
// Append SourceID attribute
acount++;
// Append CompilationID attribute
acount++;
}
if (innerClasses != null) {
acount++;
}
}
result &= ~ANNOTATION;
result |= ACC_BRIDGE;
result |= ACC_VARARGS;
return result;
}
long mod = 0;
try {
} catch (SecurityException e) {
}
return mod;
}
}