src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java

Mon, 16 Oct 2017 16:07:48 +0800

author
aoqi
date
Mon, 16 Oct 2017 16:07:48 +0800
changeset 2893
ca5783d9a597
parent 2717
11743872bfc9
parent 2702
9ca8d8713094
permissions
-rw-r--r--

merge

aoqi@0 1 /*
vromero@2709 2 * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation. Oracle designates this
aoqi@0 8 * particular file as subject to the "Classpath" exception as provided
aoqi@0 9 * by Oracle in the LICENSE file that accompanied this code.
aoqi@0 10 *
aoqi@0 11 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 14 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 15 * accompanied this code).
aoqi@0 16 *
aoqi@0 17 * You should have received a copy of the GNU General Public License version
aoqi@0 18 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 20 *
aoqi@0 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 22 * or visit www.oracle.com if you need additional information or have any
aoqi@0 23 * questions.
aoqi@0 24 */
aoqi@0 25
aoqi@0 26 package com.sun.tools.javac.jvm;
aoqi@0 27
aoqi@0 28 import java.io.*;
aoqi@0 29 import java.util.LinkedHashMap;
aoqi@0 30 import java.util.Map;
aoqi@0 31 import java.util.Set;
aoqi@0 32 import java.util.HashSet;
aoqi@0 33
aoqi@0 34 import javax.tools.JavaFileManager;
aoqi@0 35 import javax.tools.FileObject;
aoqi@0 36 import javax.tools.JavaFileObject;
aoqi@0 37
aoqi@0 38 import com.sun.tools.javac.code.*;
aoqi@0 39 import com.sun.tools.javac.code.Attribute.RetentionPolicy;
aoqi@0 40 import com.sun.tools.javac.code.Symbol.*;
aoqi@0 41 import com.sun.tools.javac.code.Type.*;
aoqi@0 42 import com.sun.tools.javac.code.Types.UniqueType;
aoqi@0 43 import com.sun.tools.javac.file.BaseFileObject;
aoqi@0 44 import com.sun.tools.javac.jvm.Pool.DynamicMethod;
aoqi@0 45 import com.sun.tools.javac.jvm.Pool.Method;
aoqi@0 46 import com.sun.tools.javac.jvm.Pool.MethodHandle;
aoqi@0 47 import com.sun.tools.javac.jvm.Pool.Variable;
aoqi@0 48 import com.sun.tools.javac.util.*;
aoqi@0 49
aoqi@0 50 import static com.sun.tools.javac.code.Flags.*;
aoqi@0 51 import static com.sun.tools.javac.code.Kinds.*;
aoqi@0 52 import static com.sun.tools.javac.code.TypeTag.*;
aoqi@0 53 import static com.sun.tools.javac.jvm.UninitializedType.*;
aoqi@0 54 import static com.sun.tools.javac.main.Option.*;
aoqi@0 55 import static javax.tools.StandardLocation.CLASS_OUTPUT;
aoqi@0 56
aoqi@0 57 /** This class provides operations to map an internal symbol table graph
aoqi@0 58 * rooted in a ClassSymbol into a classfile.
aoqi@0 59 *
aoqi@0 60 * <p><b>This is NOT part of any supported API.
aoqi@0 61 * If you write code that depends on this, you do so at your own risk.
aoqi@0 62 * This code and its internal interfaces are subject to change or
aoqi@0 63 * deletion without notice.</b>
aoqi@0 64 */
aoqi@0 65 public class ClassWriter extends ClassFile {
aoqi@0 66 protected static final Context.Key<ClassWriter> classWriterKey =
aoqi@0 67 new Context.Key<ClassWriter>();
aoqi@0 68
aoqi@0 69 private final Options options;
aoqi@0 70
aoqi@0 71 /** Switch: verbose output.
aoqi@0 72 */
aoqi@0 73 private boolean verbose;
aoqi@0 74
aoqi@0 75 /** Switch: scramble private field names.
aoqi@0 76 */
aoqi@0 77 private boolean scramble;
aoqi@0 78
aoqi@0 79 /** Switch: scramble all field names.
aoqi@0 80 */
aoqi@0 81 private boolean scrambleAll;
aoqi@0 82
aoqi@0 83 /** Switch: retrofit mode.
aoqi@0 84 */
aoqi@0 85 private boolean retrofit;
aoqi@0 86
aoqi@0 87 /** Switch: emit source file attribute.
aoqi@0 88 */
aoqi@0 89 private boolean emitSourceFile;
aoqi@0 90
aoqi@0 91 /** Switch: generate CharacterRangeTable attribute.
aoqi@0 92 */
aoqi@0 93 private boolean genCrt;
aoqi@0 94
aoqi@0 95 /** Switch: describe the generated stackmap.
aoqi@0 96 */
aoqi@0 97 boolean debugstackmap;
aoqi@0 98
aoqi@0 99 /**
aoqi@0 100 * Target class version.
aoqi@0 101 */
aoqi@0 102 private Target target;
aoqi@0 103
aoqi@0 104 /**
aoqi@0 105 * Source language version.
aoqi@0 106 */
aoqi@0 107 private Source source;
aoqi@0 108
aoqi@0 109 /** Type utilities. */
aoqi@0 110 private Types types;
aoqi@0 111
aoqi@0 112 /** The initial sizes of the data and constant pool buffers.
aoqi@0 113 * Sizes are increased when buffers get full.
aoqi@0 114 */
aoqi@0 115 static final int DATA_BUF_SIZE = 0x0fff0;
aoqi@0 116 static final int POOL_BUF_SIZE = 0x1fff0;
aoqi@0 117
aoqi@0 118 /** An output buffer for member info.
aoqi@0 119 */
aoqi@0 120 ByteBuffer databuf = new ByteBuffer(DATA_BUF_SIZE);
aoqi@0 121
aoqi@0 122 /** An output buffer for the constant pool.
aoqi@0 123 */
aoqi@0 124 ByteBuffer poolbuf = new ByteBuffer(POOL_BUF_SIZE);
aoqi@0 125
aoqi@0 126 /** The constant pool.
aoqi@0 127 */
aoqi@0 128 Pool pool;
aoqi@0 129
aoqi@0 130 /** The inner classes to be written, as a set.
aoqi@0 131 */
aoqi@0 132 Set<ClassSymbol> innerClasses;
aoqi@0 133
aoqi@0 134 /** The inner classes to be written, as a queue where
aoqi@0 135 * enclosing classes come first.
aoqi@0 136 */
aoqi@0 137 ListBuffer<ClassSymbol> innerClassesQueue;
aoqi@0 138
aoqi@0 139 /** The bootstrap methods to be written in the corresponding class attribute
aoqi@0 140 * (one for each invokedynamic)
aoqi@0 141 */
aoqi@0 142 Map<DynamicMethod, MethodHandle> bootstrapMethods;
aoqi@0 143
aoqi@0 144 /** The log to use for verbose output.
aoqi@0 145 */
aoqi@0 146 private final Log log;
aoqi@0 147
aoqi@0 148 /** The name table. */
aoqi@0 149 private final Names names;
aoqi@0 150
aoqi@0 151 /** Access to files. */
aoqi@0 152 private final JavaFileManager fileManager;
aoqi@0 153
aoqi@0 154 /** Sole signature generator */
aoqi@0 155 private final CWSignatureGenerator signatureGen;
aoqi@0 156
aoqi@0 157 /** The tags and constants used in compressed stackmap. */
aoqi@0 158 static final int SAME_FRAME_SIZE = 64;
aoqi@0 159 static final int SAME_LOCALS_1_STACK_ITEM_EXTENDED = 247;
aoqi@0 160 static final int SAME_FRAME_EXTENDED = 251;
aoqi@0 161 static final int FULL_FRAME = 255;
aoqi@0 162 static final int MAX_LOCAL_LENGTH_DIFF = 4;
aoqi@0 163
aoqi@0 164 /** Get the ClassWriter instance for this context. */
aoqi@0 165 public static ClassWriter instance(Context context) {
aoqi@0 166 ClassWriter instance = context.get(classWriterKey);
aoqi@0 167 if (instance == null)
aoqi@0 168 instance = new ClassWriter(context);
aoqi@0 169 return instance;
aoqi@0 170 }
aoqi@0 171
aoqi@0 172 /** Construct a class writer, given an options table.
aoqi@0 173 */
aoqi@0 174 protected ClassWriter(Context context) {
aoqi@0 175 context.put(classWriterKey, this);
aoqi@0 176
aoqi@0 177 log = Log.instance(context);
aoqi@0 178 names = Names.instance(context);
aoqi@0 179 options = Options.instance(context);
aoqi@0 180 target = Target.instance(context);
aoqi@0 181 source = Source.instance(context);
aoqi@0 182 types = Types.instance(context);
aoqi@0 183 fileManager = context.get(JavaFileManager.class);
aoqi@0 184 signatureGen = new CWSignatureGenerator(types);
aoqi@0 185
aoqi@0 186 verbose = options.isSet(VERBOSE);
aoqi@0 187 scramble = options.isSet("-scramble");
aoqi@0 188 scrambleAll = options.isSet("-scrambleAll");
aoqi@0 189 retrofit = options.isSet("-retrofit");
aoqi@0 190 genCrt = options.isSet(XJCOV);
aoqi@0 191 debugstackmap = options.isSet("debugstackmap");
aoqi@0 192
aoqi@0 193 emitSourceFile = options.isUnset(G_CUSTOM) ||
aoqi@0 194 options.isSet(G_CUSTOM, "source");
aoqi@0 195
aoqi@0 196 String dumpModFlags = options.get("dumpmodifiers");
aoqi@0 197 dumpClassModifiers =
aoqi@0 198 (dumpModFlags != null && dumpModFlags.indexOf('c') != -1);
aoqi@0 199 dumpFieldModifiers =
aoqi@0 200 (dumpModFlags != null && dumpModFlags.indexOf('f') != -1);
aoqi@0 201 dumpInnerClassModifiers =
aoqi@0 202 (dumpModFlags != null && dumpModFlags.indexOf('i') != -1);
aoqi@0 203 dumpMethodModifiers =
aoqi@0 204 (dumpModFlags != null && dumpModFlags.indexOf('m') != -1);
aoqi@0 205 }
aoqi@0 206
aoqi@0 207 /******************************************************************
aoqi@0 208 * Diagnostics: dump generated class names and modifiers
aoqi@0 209 ******************************************************************/
aoqi@0 210
aoqi@0 211 /** Value of option 'dumpmodifiers' is a string
aoqi@0 212 * indicating which modifiers should be dumped for debugging:
aoqi@0 213 * 'c' -- classes
aoqi@0 214 * 'f' -- fields
aoqi@0 215 * 'i' -- innerclass attributes
aoqi@0 216 * 'm' -- methods
aoqi@0 217 * For example, to dump everything:
aoqi@0 218 * javac -XDdumpmodifiers=cifm MyProg.java
aoqi@0 219 */
aoqi@0 220 private final boolean dumpClassModifiers; // -XDdumpmodifiers=c
aoqi@0 221 private final boolean dumpFieldModifiers; // -XDdumpmodifiers=f
aoqi@0 222 private final boolean dumpInnerClassModifiers; // -XDdumpmodifiers=i
aoqi@0 223 private final boolean dumpMethodModifiers; // -XDdumpmodifiers=m
aoqi@0 224
aoqi@0 225
aoqi@0 226 /** Return flags as a string, separated by " ".
aoqi@0 227 */
aoqi@0 228 public static String flagNames(long flags) {
aoqi@0 229 StringBuilder sbuf = new StringBuilder();
aoqi@0 230 int i = 0;
aoqi@0 231 long f = flags & StandardFlags;
aoqi@0 232 while (f != 0) {
aoqi@0 233 if ((f & 1) != 0) {
aoqi@0 234 sbuf.append(" ");
aoqi@0 235 sbuf.append(flagName[i]);
aoqi@0 236 }
aoqi@0 237 f = f >> 1;
aoqi@0 238 i++;
aoqi@0 239 }
aoqi@0 240 return sbuf.toString();
aoqi@0 241 }
aoqi@0 242 //where
aoqi@0 243 private final static String[] flagName = {
aoqi@0 244 "PUBLIC", "PRIVATE", "PROTECTED", "STATIC", "FINAL",
aoqi@0 245 "SUPER", "VOLATILE", "TRANSIENT", "NATIVE", "INTERFACE",
aoqi@0 246 "ABSTRACT", "STRICTFP"};
aoqi@0 247
aoqi@0 248 /******************************************************************
aoqi@0 249 * Output routines
aoqi@0 250 ******************************************************************/
aoqi@0 251
aoqi@0 252 /** Write a character into given byte buffer;
aoqi@0 253 * byte buffer will not be grown.
aoqi@0 254 */
aoqi@0 255 void putChar(ByteBuffer buf, int op, int x) {
aoqi@0 256 buf.elems[op ] = (byte)((x >> 8) & 0xFF);
aoqi@0 257 buf.elems[op+1] = (byte)((x ) & 0xFF);
aoqi@0 258 }
aoqi@0 259
aoqi@0 260 /** Write an integer into given byte buffer;
aoqi@0 261 * byte buffer will not be grown.
aoqi@0 262 */
aoqi@0 263 void putInt(ByteBuffer buf, int adr, int x) {
aoqi@0 264 buf.elems[adr ] = (byte)((x >> 24) & 0xFF);
aoqi@0 265 buf.elems[adr+1] = (byte)((x >> 16) & 0xFF);
aoqi@0 266 buf.elems[adr+2] = (byte)((x >> 8) & 0xFF);
aoqi@0 267 buf.elems[adr+3] = (byte)((x ) & 0xFF);
aoqi@0 268 }
aoqi@0 269
aoqi@0 270 /**
aoqi@0 271 * Signature Generation
aoqi@0 272 */
aoqi@0 273 private class CWSignatureGenerator extends Types.SignatureGenerator {
aoqi@0 274
aoqi@0 275 /**
aoqi@0 276 * An output buffer for type signatures.
aoqi@0 277 */
aoqi@0 278 ByteBuffer sigbuf = new ByteBuffer();
aoqi@0 279
aoqi@0 280 CWSignatureGenerator(Types types) {
aoqi@0 281 super(types);
aoqi@0 282 }
aoqi@0 283
aoqi@0 284 /**
aoqi@0 285 * Assemble signature of given type in string buffer.
aoqi@0 286 * Check for uninitialized types before calling the general case.
aoqi@0 287 */
aoqi@0 288 @Override
aoqi@0 289 public void assembleSig(Type type) {
aoqi@0 290 type = type.unannotatedType();
aoqi@0 291 switch (type.getTag()) {
aoqi@0 292 case UNINITIALIZED_THIS:
aoqi@0 293 case UNINITIALIZED_OBJECT:
aoqi@0 294 // we don't yet have a spec for uninitialized types in the
aoqi@0 295 // local variable table
aoqi@0 296 assembleSig(types.erasure(((UninitializedType)type).qtype));
aoqi@0 297 break;
aoqi@0 298 default:
aoqi@0 299 super.assembleSig(type);
aoqi@0 300 }
aoqi@0 301 }
aoqi@0 302
aoqi@0 303 @Override
aoqi@0 304 protected void append(char ch) {
aoqi@0 305 sigbuf.appendByte(ch);
aoqi@0 306 }
aoqi@0 307
aoqi@0 308 @Override
aoqi@0 309 protected void append(byte[] ba) {
aoqi@0 310 sigbuf.appendBytes(ba);
aoqi@0 311 }
aoqi@0 312
aoqi@0 313 @Override
aoqi@0 314 protected void append(Name name) {
aoqi@0 315 sigbuf.appendName(name);
aoqi@0 316 }
aoqi@0 317
aoqi@0 318 @Override
aoqi@0 319 protected void classReference(ClassSymbol c) {
aoqi@0 320 enterInner(c);
aoqi@0 321 }
aoqi@0 322
aoqi@0 323 private void reset() {
aoqi@0 324 sigbuf.reset();
aoqi@0 325 }
aoqi@0 326
aoqi@0 327 private Name toName() {
aoqi@0 328 return sigbuf.toName(names);
aoqi@0 329 }
aoqi@0 330
aoqi@0 331 private boolean isEmpty() {
aoqi@0 332 return sigbuf.length == 0;
aoqi@0 333 }
aoqi@0 334 }
aoqi@0 335
aoqi@0 336 /**
aoqi@0 337 * Return signature of given type
aoqi@0 338 */
aoqi@0 339 Name typeSig(Type type) {
aoqi@0 340 Assert.check(signatureGen.isEmpty());
aoqi@0 341 //- System.out.println(" ? " + type);
aoqi@0 342 signatureGen.assembleSig(type);
aoqi@0 343 Name n = signatureGen.toName();
aoqi@0 344 signatureGen.reset();
aoqi@0 345 //- System.out.println(" " + n);
aoqi@0 346 return n;
aoqi@0 347 }
aoqi@0 348
aoqi@0 349 /** Given a type t, return the extended class name of its erasure in
aoqi@0 350 * external representation.
aoqi@0 351 */
aoqi@0 352 public Name xClassName(Type t) {
aoqi@0 353 if (t.hasTag(CLASS)) {
aoqi@0 354 return names.fromUtf(externalize(t.tsym.flatName()));
aoqi@0 355 } else if (t.hasTag(ARRAY)) {
aoqi@0 356 return typeSig(types.erasure(t));
aoqi@0 357 } else {
aoqi@0 358 throw new AssertionError("xClassName");
aoqi@0 359 }
aoqi@0 360 }
aoqi@0 361
aoqi@0 362 /******************************************************************
aoqi@0 363 * Writing the Constant Pool
aoqi@0 364 ******************************************************************/
aoqi@0 365
aoqi@0 366 /** Thrown when the constant pool is over full.
aoqi@0 367 */
aoqi@0 368 public static class PoolOverflow extends Exception {
aoqi@0 369 private static final long serialVersionUID = 0;
aoqi@0 370 public PoolOverflow() {}
aoqi@0 371 }
aoqi@0 372 public static class StringOverflow extends Exception {
aoqi@0 373 private static final long serialVersionUID = 0;
aoqi@0 374 public final String value;
aoqi@0 375 public StringOverflow(String s) {
aoqi@0 376 value = s;
aoqi@0 377 }
aoqi@0 378 }
aoqi@0 379
aoqi@0 380 /** Write constant pool to pool buffer.
aoqi@0 381 * Note: during writing, constant pool
aoqi@0 382 * might grow since some parts of constants still need to be entered.
aoqi@0 383 */
aoqi@0 384 void writePool(Pool pool) throws PoolOverflow, StringOverflow {
aoqi@0 385 int poolCountIdx = poolbuf.length;
aoqi@0 386 poolbuf.appendChar(0);
aoqi@0 387 int i = 1;
aoqi@0 388 while (i < pool.pp) {
aoqi@0 389 Object value = pool.pool[i];
aoqi@0 390 Assert.checkNonNull(value);
aoqi@0 391 if (value instanceof Method || value instanceof Variable)
aoqi@0 392 value = ((DelegatedSymbol)value).getUnderlyingSymbol();
aoqi@0 393
aoqi@0 394 if (value instanceof MethodSymbol) {
aoqi@0 395 MethodSymbol m = (MethodSymbol)value;
aoqi@0 396 if (!m.isDynamic()) {
aoqi@0 397 poolbuf.appendByte((m.owner.flags() & INTERFACE) != 0
aoqi@0 398 ? CONSTANT_InterfaceMethodref
aoqi@0 399 : CONSTANT_Methodref);
aoqi@0 400 poolbuf.appendChar(pool.put(m.owner));
aoqi@0 401 poolbuf.appendChar(pool.put(nameType(m)));
aoqi@0 402 } else {
aoqi@0 403 //invokedynamic
aoqi@0 404 DynamicMethodSymbol dynSym = (DynamicMethodSymbol)m;
aoqi@0 405 MethodHandle handle = new MethodHandle(dynSym.bsmKind, dynSym.bsm, types);
aoqi@0 406 DynamicMethod dynMeth = new DynamicMethod(dynSym, types);
aoqi@0 407 bootstrapMethods.put(dynMeth, handle);
aoqi@0 408 //init cp entries
aoqi@0 409 pool.put(names.BootstrapMethods);
aoqi@0 410 pool.put(handle);
aoqi@0 411 for (Object staticArg : dynSym.staticArgs) {
aoqi@0 412 pool.put(staticArg);
aoqi@0 413 }
aoqi@0 414 poolbuf.appendByte(CONSTANT_InvokeDynamic);
aoqi@0 415 poolbuf.appendChar(bootstrapMethods.size() - 1);
aoqi@0 416 poolbuf.appendChar(pool.put(nameType(dynSym)));
aoqi@0 417 }
aoqi@0 418 } else if (value instanceof VarSymbol) {
aoqi@0 419 VarSymbol v = (VarSymbol)value;
aoqi@0 420 poolbuf.appendByte(CONSTANT_Fieldref);
aoqi@0 421 poolbuf.appendChar(pool.put(v.owner));
aoqi@0 422 poolbuf.appendChar(pool.put(nameType(v)));
aoqi@0 423 } else if (value instanceof Name) {
aoqi@0 424 poolbuf.appendByte(CONSTANT_Utf8);
aoqi@0 425 byte[] bs = ((Name)value).toUtf();
aoqi@0 426 poolbuf.appendChar(bs.length);
aoqi@0 427 poolbuf.appendBytes(bs, 0, bs.length);
aoqi@0 428 if (bs.length > Pool.MAX_STRING_LENGTH)
aoqi@0 429 throw new StringOverflow(value.toString());
aoqi@0 430 } else if (value instanceof ClassSymbol) {
aoqi@0 431 ClassSymbol c = (ClassSymbol)value;
aoqi@0 432 if (c.owner.kind == TYP) pool.put(c.owner);
aoqi@0 433 poolbuf.appendByte(CONSTANT_Class);
aoqi@0 434 if (c.type.hasTag(ARRAY)) {
aoqi@0 435 poolbuf.appendChar(pool.put(typeSig(c.type)));
aoqi@0 436 } else {
aoqi@0 437 poolbuf.appendChar(pool.put(names.fromUtf(externalize(c.flatname))));
aoqi@0 438 enterInner(c);
aoqi@0 439 }
aoqi@0 440 } else if (value instanceof NameAndType) {
aoqi@0 441 NameAndType nt = (NameAndType)value;
aoqi@0 442 poolbuf.appendByte(CONSTANT_NameandType);
aoqi@0 443 poolbuf.appendChar(pool.put(nt.name));
aoqi@0 444 poolbuf.appendChar(pool.put(typeSig(nt.uniqueType.type)));
aoqi@0 445 } else if (value instanceof Integer) {
aoqi@0 446 poolbuf.appendByte(CONSTANT_Integer);
aoqi@0 447 poolbuf.appendInt(((Integer)value).intValue());
aoqi@0 448 } else if (value instanceof Long) {
aoqi@0 449 poolbuf.appendByte(CONSTANT_Long);
aoqi@0 450 poolbuf.appendLong(((Long)value).longValue());
aoqi@0 451 i++;
aoqi@0 452 } else if (value instanceof Float) {
aoqi@0 453 poolbuf.appendByte(CONSTANT_Float);
aoqi@0 454 poolbuf.appendFloat(((Float)value).floatValue());
aoqi@0 455 } else if (value instanceof Double) {
aoqi@0 456 poolbuf.appendByte(CONSTANT_Double);
aoqi@0 457 poolbuf.appendDouble(((Double)value).doubleValue());
aoqi@0 458 i++;
aoqi@0 459 } else if (value instanceof String) {
aoqi@0 460 poolbuf.appendByte(CONSTANT_String);
aoqi@0 461 poolbuf.appendChar(pool.put(names.fromString((String)value)));
aoqi@0 462 } else if (value instanceof UniqueType) {
aoqi@0 463 Type type = ((UniqueType)value).type;
aoqi@0 464 if (type instanceof MethodType) {
aoqi@0 465 poolbuf.appendByte(CONSTANT_MethodType);
aoqi@0 466 poolbuf.appendChar(pool.put(typeSig((MethodType)type)));
aoqi@0 467 } else {
aoqi@0 468 if (type.hasTag(CLASS)) enterInner((ClassSymbol)type.tsym);
aoqi@0 469 poolbuf.appendByte(CONSTANT_Class);
aoqi@0 470 poolbuf.appendChar(pool.put(xClassName(type)));
aoqi@0 471 }
aoqi@0 472 } else if (value instanceof MethodHandle) {
aoqi@0 473 MethodHandle ref = (MethodHandle)value;
aoqi@0 474 poolbuf.appendByte(CONSTANT_MethodHandle);
aoqi@0 475 poolbuf.appendByte(ref.refKind);
aoqi@0 476 poolbuf.appendChar(pool.put(ref.refSym));
aoqi@0 477 } else {
aoqi@0 478 Assert.error("writePool " + value);
aoqi@0 479 }
aoqi@0 480 i++;
aoqi@0 481 }
aoqi@0 482 if (pool.pp > Pool.MAX_ENTRIES)
aoqi@0 483 throw new PoolOverflow();
aoqi@0 484 putChar(poolbuf, poolCountIdx, pool.pp);
aoqi@0 485 }
aoqi@0 486
aoqi@0 487 /** Given a field, return its name.
aoqi@0 488 */
aoqi@0 489 Name fieldName(Symbol sym) {
aoqi@0 490 if (scramble && (sym.flags() & PRIVATE) != 0 ||
aoqi@0 491 scrambleAll && (sym.flags() & (PROTECTED | PUBLIC)) == 0)
aoqi@0 492 return names.fromString("_$" + sym.name.getIndex());
aoqi@0 493 else
aoqi@0 494 return sym.name;
aoqi@0 495 }
aoqi@0 496
aoqi@0 497 /** Given a symbol, return its name-and-type.
aoqi@0 498 */
aoqi@0 499 NameAndType nameType(Symbol sym) {
aoqi@0 500 return new NameAndType(fieldName(sym),
aoqi@0 501 retrofit
aoqi@0 502 ? sym.erasure(types)
aoqi@0 503 : sym.externalType(types), types);
aoqi@0 504 // if we retrofit, then the NameAndType has been read in as is
aoqi@0 505 // and no change is necessary. If we compile normally, the
aoqi@0 506 // NameAndType is generated from a symbol reference, and the
aoqi@0 507 // adjustment of adding an additional this$n parameter needs to be made.
aoqi@0 508 }
aoqi@0 509
aoqi@0 510 /******************************************************************
aoqi@0 511 * Writing Attributes
aoqi@0 512 ******************************************************************/
aoqi@0 513
aoqi@0 514 /** Write header for an attribute to data buffer and return
aoqi@0 515 * position past attribute length index.
aoqi@0 516 */
aoqi@0 517 int writeAttr(Name attrName) {
aoqi@0 518 databuf.appendChar(pool.put(attrName));
aoqi@0 519 databuf.appendInt(0);
aoqi@0 520 return databuf.length;
aoqi@0 521 }
aoqi@0 522
aoqi@0 523 /** Fill in attribute length.
aoqi@0 524 */
aoqi@0 525 void endAttr(int index) {
aoqi@0 526 putInt(databuf, index - 4, databuf.length - index);
aoqi@0 527 }
aoqi@0 528
aoqi@0 529 /** Leave space for attribute count and return index for
aoqi@0 530 * number of attributes field.
aoqi@0 531 */
aoqi@0 532 int beginAttrs() {
aoqi@0 533 databuf.appendChar(0);
aoqi@0 534 return databuf.length;
aoqi@0 535 }
aoqi@0 536
aoqi@0 537 /** Fill in number of attributes.
aoqi@0 538 */
aoqi@0 539 void endAttrs(int index, int count) {
aoqi@0 540 putChar(databuf, index - 2, count);
aoqi@0 541 }
aoqi@0 542
aoqi@0 543 /** Write the EnclosingMethod attribute if needed.
aoqi@0 544 * Returns the number of attributes written (0 or 1).
aoqi@0 545 */
aoqi@0 546 int writeEnclosingMethodAttribute(ClassSymbol c) {
aoqi@0 547 if (!target.hasEnclosingMethodAttribute())
aoqi@0 548 return 0;
aoqi@0 549 return writeEnclosingMethodAttribute(names.EnclosingMethod, c);
aoqi@0 550 }
aoqi@0 551
aoqi@0 552 /** Write the EnclosingMethod attribute with a specified name.
aoqi@0 553 * Returns the number of attributes written (0 or 1).
aoqi@0 554 */
aoqi@0 555 protected int writeEnclosingMethodAttribute(Name attributeName, ClassSymbol c) {
aoqi@0 556 if (c.owner.kind != MTH && // neither a local class
aoqi@0 557 c.name != names.empty) // nor anonymous
aoqi@0 558 return 0;
aoqi@0 559
aoqi@0 560 int alenIdx = writeAttr(attributeName);
aoqi@0 561 ClassSymbol enclClass = c.owner.enclClass();
aoqi@0 562 MethodSymbol enclMethod =
aoqi@0 563 (c.owner.type == null // local to init block
aoqi@0 564 || c.owner.kind != MTH) // or member init
aoqi@0 565 ? null
aoqi@0 566 : (MethodSymbol)c.owner;
aoqi@0 567 databuf.appendChar(pool.put(enclClass));
aoqi@0 568 databuf.appendChar(enclMethod == null ? 0 : pool.put(nameType(c.owner)));
aoqi@0 569 endAttr(alenIdx);
aoqi@0 570 return 1;
aoqi@0 571 }
aoqi@0 572
aoqi@0 573 /** Write flag attributes; return number of attributes written.
aoqi@0 574 */
aoqi@0 575 int writeFlagAttrs(long flags) {
aoqi@0 576 int acount = 0;
aoqi@0 577 if ((flags & DEPRECATED) != 0) {
aoqi@0 578 int alenIdx = writeAttr(names.Deprecated);
aoqi@0 579 endAttr(alenIdx);
aoqi@0 580 acount++;
aoqi@0 581 }
aoqi@0 582 if ((flags & ENUM) != 0 && !target.useEnumFlag()) {
aoqi@0 583 int alenIdx = writeAttr(names.Enum);
aoqi@0 584 endAttr(alenIdx);
aoqi@0 585 acount++;
aoqi@0 586 }
aoqi@0 587 if ((flags & SYNTHETIC) != 0 && !target.useSyntheticFlag()) {
aoqi@0 588 int alenIdx = writeAttr(names.Synthetic);
aoqi@0 589 endAttr(alenIdx);
aoqi@0 590 acount++;
aoqi@0 591 }
aoqi@0 592 if ((flags & BRIDGE) != 0 && !target.useBridgeFlag()) {
aoqi@0 593 int alenIdx = writeAttr(names.Bridge);
aoqi@0 594 endAttr(alenIdx);
aoqi@0 595 acount++;
aoqi@0 596 }
aoqi@0 597 if ((flags & VARARGS) != 0 && !target.useVarargsFlag()) {
aoqi@0 598 int alenIdx = writeAttr(names.Varargs);
aoqi@0 599 endAttr(alenIdx);
aoqi@0 600 acount++;
aoqi@0 601 }
aoqi@0 602 if ((flags & ANNOTATION) != 0 && !target.useAnnotationFlag()) {
aoqi@0 603 int alenIdx = writeAttr(names.Annotation);
aoqi@0 604 endAttr(alenIdx);
aoqi@0 605 acount++;
aoqi@0 606 }
aoqi@0 607 return acount;
aoqi@0 608 }
aoqi@0 609
aoqi@0 610 /** Write member (field or method) attributes;
aoqi@0 611 * return number of attributes written.
aoqi@0 612 */
aoqi@0 613 int writeMemberAttrs(Symbol sym) {
aoqi@0 614 int acount = writeFlagAttrs(sym.flags());
aoqi@0 615 long flags = sym.flags();
aoqi@0 616 if (source.allowGenerics() &&
aoqi@0 617 (flags & (SYNTHETIC|BRIDGE)) != SYNTHETIC &&
aoqi@0 618 (flags & ANONCONSTR) == 0 &&
aoqi@0 619 (!types.isSameType(sym.type, sym.erasure(types)) ||
aoqi@0 620 signatureGen.hasTypeVar(sym.type.getThrownTypes()))) {
aoqi@0 621 // note that a local class with captured variables
aoqi@0 622 // will get a signature attribute
aoqi@0 623 int alenIdx = writeAttr(names.Signature);
aoqi@0 624 databuf.appendChar(pool.put(typeSig(sym.type)));
aoqi@0 625 endAttr(alenIdx);
aoqi@0 626 acount++;
aoqi@0 627 }
aoqi@0 628 acount += writeJavaAnnotations(sym.getRawAttributes());
aoqi@0 629 acount += writeTypeAnnotations(sym.getRawTypeAttributes(), false);
aoqi@0 630 return acount;
aoqi@0 631 }
aoqi@0 632
aoqi@0 633 /**
aoqi@0 634 * Write method parameter names attribute.
aoqi@0 635 */
aoqi@0 636 int writeMethodParametersAttr(MethodSymbol m) {
aoqi@0 637 MethodType ty = m.externalType(types).asMethodType();
aoqi@0 638 final int allparams = ty.argtypes.size();
aoqi@0 639 if (m.params != null && allparams != 0) {
aoqi@0 640 final int attrIndex = writeAttr(names.MethodParameters);
aoqi@0 641 databuf.appendByte(allparams);
aoqi@0 642 // Write extra parameters first
aoqi@0 643 for (VarSymbol s : m.extraParams) {
aoqi@0 644 final int flags =
aoqi@0 645 ((int) s.flags() & (FINAL | SYNTHETIC | MANDATED)) |
aoqi@0 646 ((int) m.flags() & SYNTHETIC);
aoqi@0 647 databuf.appendChar(pool.put(s.name));
aoqi@0 648 databuf.appendChar(flags);
aoqi@0 649 }
aoqi@0 650 // Now write the real parameters
aoqi@0 651 for (VarSymbol s : m.params) {
aoqi@0 652 final int flags =
aoqi@0 653 ((int) s.flags() & (FINAL | SYNTHETIC | MANDATED)) |
aoqi@0 654 ((int) m.flags() & SYNTHETIC);
aoqi@0 655 databuf.appendChar(pool.put(s.name));
aoqi@0 656 databuf.appendChar(flags);
aoqi@0 657 }
aoqi@0 658 // Now write the captured locals
aoqi@0 659 for (VarSymbol s : m.capturedLocals) {
aoqi@0 660 final int flags =
aoqi@0 661 ((int) s.flags() & (FINAL | SYNTHETIC | MANDATED)) |
aoqi@0 662 ((int) m.flags() & SYNTHETIC);
aoqi@0 663 databuf.appendChar(pool.put(s.name));
aoqi@0 664 databuf.appendChar(flags);
aoqi@0 665 }
aoqi@0 666 endAttr(attrIndex);
aoqi@0 667 return 1;
aoqi@0 668 } else
aoqi@0 669 return 0;
aoqi@0 670 }
aoqi@0 671
aoqi@0 672
aoqi@0 673 /** Write method parameter annotations;
aoqi@0 674 * return number of attributes written.
aoqi@0 675 */
aoqi@0 676 int writeParameterAttrs(MethodSymbol m) {
aoqi@0 677 boolean hasVisible = false;
aoqi@0 678 boolean hasInvisible = false;
aoqi@0 679 if (m.params != null) {
aoqi@0 680 for (VarSymbol s : m.params) {
aoqi@0 681 for (Attribute.Compound a : s.getRawAttributes()) {
aoqi@0 682 switch (types.getRetention(a)) {
aoqi@0 683 case SOURCE: break;
aoqi@0 684 case CLASS: hasInvisible = true; break;
aoqi@0 685 case RUNTIME: hasVisible = true; break;
aoqi@0 686 default: ;// /* fail soft */ throw new AssertionError(vis);
aoqi@0 687 }
aoqi@0 688 }
aoqi@0 689 }
aoqi@0 690 }
aoqi@0 691
aoqi@0 692 int attrCount = 0;
aoqi@0 693 if (hasVisible) {
aoqi@0 694 int attrIndex = writeAttr(names.RuntimeVisibleParameterAnnotations);
aoqi@0 695 databuf.appendByte(m.params.length());
aoqi@0 696 for (VarSymbol s : m.params) {
aoqi@0 697 ListBuffer<Attribute.Compound> buf = new ListBuffer<Attribute.Compound>();
aoqi@0 698 for (Attribute.Compound a : s.getRawAttributes())
aoqi@0 699 if (types.getRetention(a) == RetentionPolicy.RUNTIME)
aoqi@0 700 buf.append(a);
aoqi@0 701 databuf.appendChar(buf.length());
aoqi@0 702 for (Attribute.Compound a : buf)
aoqi@0 703 writeCompoundAttribute(a);
aoqi@0 704 }
aoqi@0 705 endAttr(attrIndex);
aoqi@0 706 attrCount++;
aoqi@0 707 }
aoqi@0 708 if (hasInvisible) {
aoqi@0 709 int attrIndex = writeAttr(names.RuntimeInvisibleParameterAnnotations);
aoqi@0 710 databuf.appendByte(m.params.length());
aoqi@0 711 for (VarSymbol s : m.params) {
aoqi@0 712 ListBuffer<Attribute.Compound> buf = new ListBuffer<Attribute.Compound>();
aoqi@0 713 for (Attribute.Compound a : s.getRawAttributes())
aoqi@0 714 if (types.getRetention(a) == RetentionPolicy.CLASS)
aoqi@0 715 buf.append(a);
aoqi@0 716 databuf.appendChar(buf.length());
aoqi@0 717 for (Attribute.Compound a : buf)
aoqi@0 718 writeCompoundAttribute(a);
aoqi@0 719 }
aoqi@0 720 endAttr(attrIndex);
aoqi@0 721 attrCount++;
aoqi@0 722 }
aoqi@0 723 return attrCount;
aoqi@0 724 }
aoqi@0 725
aoqi@0 726 /**********************************************************************
aoqi@0 727 * Writing Java-language annotations (aka metadata, attributes)
aoqi@0 728 **********************************************************************/
aoqi@0 729
aoqi@0 730 /** Write Java-language annotations; return number of JVM
aoqi@0 731 * attributes written (zero or one).
aoqi@0 732 */
aoqi@0 733 int writeJavaAnnotations(List<Attribute.Compound> attrs) {
aoqi@0 734 if (attrs.isEmpty()) return 0;
aoqi@0 735 ListBuffer<Attribute.Compound> visibles = new ListBuffer<Attribute.Compound>();
aoqi@0 736 ListBuffer<Attribute.Compound> invisibles = new ListBuffer<Attribute.Compound>();
aoqi@0 737 for (Attribute.Compound a : attrs) {
aoqi@0 738 switch (types.getRetention(a)) {
aoqi@0 739 case SOURCE: break;
aoqi@0 740 case CLASS: invisibles.append(a); break;
aoqi@0 741 case RUNTIME: visibles.append(a); break;
aoqi@0 742 default: ;// /* fail soft */ throw new AssertionError(vis);
aoqi@0 743 }
aoqi@0 744 }
aoqi@0 745
aoqi@0 746 int attrCount = 0;
aoqi@0 747 if (visibles.length() != 0) {
aoqi@0 748 int attrIndex = writeAttr(names.RuntimeVisibleAnnotations);
aoqi@0 749 databuf.appendChar(visibles.length());
aoqi@0 750 for (Attribute.Compound a : visibles)
aoqi@0 751 writeCompoundAttribute(a);
aoqi@0 752 endAttr(attrIndex);
aoqi@0 753 attrCount++;
aoqi@0 754 }
aoqi@0 755 if (invisibles.length() != 0) {
aoqi@0 756 int attrIndex = writeAttr(names.RuntimeInvisibleAnnotations);
aoqi@0 757 databuf.appendChar(invisibles.length());
aoqi@0 758 for (Attribute.Compound a : invisibles)
aoqi@0 759 writeCompoundAttribute(a);
aoqi@0 760 endAttr(attrIndex);
aoqi@0 761 attrCount++;
aoqi@0 762 }
aoqi@0 763 return attrCount;
aoqi@0 764 }
aoqi@0 765
aoqi@0 766 int writeTypeAnnotations(List<Attribute.TypeCompound> typeAnnos, boolean inCode) {
aoqi@0 767 if (typeAnnos.isEmpty()) return 0;
aoqi@0 768
aoqi@0 769 ListBuffer<Attribute.TypeCompound> visibles = new ListBuffer<>();
aoqi@0 770 ListBuffer<Attribute.TypeCompound> invisibles = new ListBuffer<>();
aoqi@0 771
aoqi@0 772 for (Attribute.TypeCompound tc : typeAnnos) {
aoqi@0 773 if (tc.hasUnknownPosition()) {
aoqi@0 774 boolean fixed = tc.tryFixPosition();
aoqi@0 775
aoqi@0 776 // Could we fix it?
aoqi@0 777 if (!fixed) {
aoqi@0 778 // This happens for nested types like @A Outer. @B Inner.
aoqi@0 779 // For method parameters we get the annotation twice! Once with
aoqi@0 780 // a valid position, once unknown.
aoqi@0 781 // TODO: find a cleaner solution.
aoqi@0 782 PrintWriter pw = log.getWriter(Log.WriterKind.ERROR);
aoqi@0 783 pw.println("ClassWriter: Position UNKNOWN in type annotation: " + tc);
aoqi@0 784 continue;
aoqi@0 785 }
aoqi@0 786 }
aoqi@0 787
aoqi@0 788 if (tc.position.type.isLocal() != inCode)
aoqi@0 789 continue;
aoqi@0 790 if (!tc.position.emitToClassfile())
aoqi@0 791 continue;
aoqi@0 792 switch (types.getRetention(tc)) {
aoqi@0 793 case SOURCE: break;
aoqi@0 794 case CLASS: invisibles.append(tc); break;
aoqi@0 795 case RUNTIME: visibles.append(tc); break;
aoqi@0 796 default: ;// /* fail soft */ throw new AssertionError(vis);
aoqi@0 797 }
aoqi@0 798 }
aoqi@0 799
aoqi@0 800 int attrCount = 0;
aoqi@0 801 if (visibles.length() != 0) {
aoqi@0 802 int attrIndex = writeAttr(names.RuntimeVisibleTypeAnnotations);
aoqi@0 803 databuf.appendChar(visibles.length());
aoqi@0 804 for (Attribute.TypeCompound p : visibles)
aoqi@0 805 writeTypeAnnotation(p);
aoqi@0 806 endAttr(attrIndex);
aoqi@0 807 attrCount++;
aoqi@0 808 }
aoqi@0 809
aoqi@0 810 if (invisibles.length() != 0) {
aoqi@0 811 int attrIndex = writeAttr(names.RuntimeInvisibleTypeAnnotations);
aoqi@0 812 databuf.appendChar(invisibles.length());
aoqi@0 813 for (Attribute.TypeCompound p : invisibles)
aoqi@0 814 writeTypeAnnotation(p);
aoqi@0 815 endAttr(attrIndex);
aoqi@0 816 attrCount++;
aoqi@0 817 }
aoqi@0 818
aoqi@0 819 return attrCount;
aoqi@0 820 }
aoqi@0 821
aoqi@0 822 /** A visitor to write an attribute including its leading
aoqi@0 823 * single-character marker.
aoqi@0 824 */
aoqi@0 825 class AttributeWriter implements Attribute.Visitor {
aoqi@0 826 public void visitConstant(Attribute.Constant _value) {
aoqi@0 827 Object value = _value.value;
aoqi@0 828 switch (_value.type.getTag()) {
aoqi@0 829 case BYTE:
aoqi@0 830 databuf.appendByte('B');
aoqi@0 831 break;
aoqi@0 832 case CHAR:
aoqi@0 833 databuf.appendByte('C');
aoqi@0 834 break;
aoqi@0 835 case SHORT:
aoqi@0 836 databuf.appendByte('S');
aoqi@0 837 break;
aoqi@0 838 case INT:
aoqi@0 839 databuf.appendByte('I');
aoqi@0 840 break;
aoqi@0 841 case LONG:
aoqi@0 842 databuf.appendByte('J');
aoqi@0 843 break;
aoqi@0 844 case FLOAT:
aoqi@0 845 databuf.appendByte('F');
aoqi@0 846 break;
aoqi@0 847 case DOUBLE:
aoqi@0 848 databuf.appendByte('D');
aoqi@0 849 break;
aoqi@0 850 case BOOLEAN:
aoqi@0 851 databuf.appendByte('Z');
aoqi@0 852 break;
aoqi@0 853 case CLASS:
aoqi@0 854 Assert.check(value instanceof String);
aoqi@0 855 databuf.appendByte('s');
aoqi@0 856 value = names.fromString(value.toString()); // CONSTANT_Utf8
aoqi@0 857 break;
aoqi@0 858 default:
aoqi@0 859 throw new AssertionError(_value.type);
aoqi@0 860 }
aoqi@0 861 databuf.appendChar(pool.put(value));
aoqi@0 862 }
aoqi@0 863 public void visitEnum(Attribute.Enum e) {
aoqi@0 864 databuf.appendByte('e');
aoqi@0 865 databuf.appendChar(pool.put(typeSig(e.value.type)));
aoqi@0 866 databuf.appendChar(pool.put(e.value.name));
aoqi@0 867 }
aoqi@0 868 public void visitClass(Attribute.Class clazz) {
aoqi@0 869 databuf.appendByte('c');
aoqi@0 870 databuf.appendChar(pool.put(typeSig(clazz.classType)));
aoqi@0 871 }
aoqi@0 872 public void visitCompound(Attribute.Compound compound) {
aoqi@0 873 databuf.appendByte('@');
aoqi@0 874 writeCompoundAttribute(compound);
aoqi@0 875 }
aoqi@0 876 public void visitError(Attribute.Error x) {
aoqi@0 877 throw new AssertionError(x);
aoqi@0 878 }
aoqi@0 879 public void visitArray(Attribute.Array array) {
aoqi@0 880 databuf.appendByte('[');
aoqi@0 881 databuf.appendChar(array.values.length);
aoqi@0 882 for (Attribute a : array.values) {
aoqi@0 883 a.accept(this);
aoqi@0 884 }
aoqi@0 885 }
aoqi@0 886 }
aoqi@0 887 AttributeWriter awriter = new AttributeWriter();
aoqi@0 888
aoqi@0 889 /** Write a compound attribute excluding the '@' marker. */
aoqi@0 890 void writeCompoundAttribute(Attribute.Compound c) {
aoqi@0 891 databuf.appendChar(pool.put(typeSig(c.type)));
aoqi@0 892 databuf.appendChar(c.values.length());
aoqi@0 893 for (Pair<Symbol.MethodSymbol,Attribute> p : c.values) {
aoqi@0 894 databuf.appendChar(pool.put(p.fst.name));
aoqi@0 895 p.snd.accept(awriter);
aoqi@0 896 }
aoqi@0 897 }
aoqi@0 898
aoqi@0 899 void writeTypeAnnotation(Attribute.TypeCompound c) {
aoqi@0 900 writePosition(c.position);
aoqi@0 901 writeCompoundAttribute(c);
aoqi@0 902 }
aoqi@0 903
aoqi@0 904 void writePosition(TypeAnnotationPosition p) {
aoqi@0 905 databuf.appendByte(p.type.targetTypeValue()); // TargetType tag is a byte
aoqi@0 906 switch (p.type) {
aoqi@0 907 // instanceof
aoqi@0 908 case INSTANCEOF:
aoqi@0 909 // new expression
aoqi@0 910 case NEW:
aoqi@0 911 // constructor/method reference receiver
aoqi@0 912 case CONSTRUCTOR_REFERENCE:
aoqi@0 913 case METHOD_REFERENCE:
aoqi@0 914 databuf.appendChar(p.offset);
aoqi@0 915 break;
aoqi@0 916 // local variable
aoqi@0 917 case LOCAL_VARIABLE:
aoqi@0 918 // resource variable
aoqi@0 919 case RESOURCE_VARIABLE:
aoqi@0 920 databuf.appendChar(p.lvarOffset.length); // for table length
aoqi@0 921 for (int i = 0; i < p.lvarOffset.length; ++i) {
aoqi@0 922 databuf.appendChar(p.lvarOffset[i]);
aoqi@0 923 databuf.appendChar(p.lvarLength[i]);
aoqi@0 924 databuf.appendChar(p.lvarIndex[i]);
aoqi@0 925 }
aoqi@0 926 break;
aoqi@0 927 // exception parameter
aoqi@0 928 case EXCEPTION_PARAMETER:
aoqi@0 929 databuf.appendChar(p.exception_index);
aoqi@0 930 break;
aoqi@0 931 // method receiver
aoqi@0 932 case METHOD_RECEIVER:
aoqi@0 933 // Do nothing
aoqi@0 934 break;
aoqi@0 935 // type parameter
aoqi@0 936 case CLASS_TYPE_PARAMETER:
aoqi@0 937 case METHOD_TYPE_PARAMETER:
aoqi@0 938 databuf.appendByte(p.parameter_index);
aoqi@0 939 break;
aoqi@0 940 // type parameter bound
aoqi@0 941 case CLASS_TYPE_PARAMETER_BOUND:
aoqi@0 942 case METHOD_TYPE_PARAMETER_BOUND:
aoqi@0 943 databuf.appendByte(p.parameter_index);
aoqi@0 944 databuf.appendByte(p.bound_index);
aoqi@0 945 break;
aoqi@0 946 // class extends or implements clause
aoqi@0 947 case CLASS_EXTENDS:
aoqi@0 948 databuf.appendChar(p.type_index);
aoqi@0 949 break;
aoqi@0 950 // throws
aoqi@0 951 case THROWS:
aoqi@0 952 databuf.appendChar(p.type_index);
aoqi@0 953 break;
aoqi@0 954 // method parameter
aoqi@0 955 case METHOD_FORMAL_PARAMETER:
aoqi@0 956 databuf.appendByte(p.parameter_index);
aoqi@0 957 break;
aoqi@0 958 // type cast
aoqi@0 959 case CAST:
aoqi@0 960 // method/constructor/reference type argument
aoqi@0 961 case CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT:
aoqi@0 962 case METHOD_INVOCATION_TYPE_ARGUMENT:
aoqi@0 963 case CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT:
aoqi@0 964 case METHOD_REFERENCE_TYPE_ARGUMENT:
aoqi@0 965 databuf.appendChar(p.offset);
aoqi@0 966 databuf.appendByte(p.type_index);
aoqi@0 967 break;
aoqi@0 968 // We don't need to worry about these
aoqi@0 969 case METHOD_RETURN:
aoqi@0 970 case FIELD:
aoqi@0 971 break;
aoqi@0 972 case UNKNOWN:
aoqi@0 973 throw new AssertionError("jvm.ClassWriter: UNKNOWN target type should never occur!");
aoqi@0 974 default:
aoqi@0 975 throw new AssertionError("jvm.ClassWriter: Unknown target type for position: " + p);
aoqi@0 976 }
aoqi@0 977
aoqi@0 978 { // Append location data for generics/arrays.
aoqi@0 979 databuf.appendByte(p.location.size());
aoqi@0 980 java.util.List<Integer> loc = TypeAnnotationPosition.getBinaryFromTypePath(p.location);
aoqi@0 981 for (int i : loc)
aoqi@0 982 databuf.appendByte((byte)i);
aoqi@0 983 }
aoqi@0 984 }
aoqi@0 985
aoqi@0 986 /**********************************************************************
aoqi@0 987 * Writing Objects
aoqi@0 988 **********************************************************************/
aoqi@0 989
aoqi@0 990 /** Enter an inner class into the `innerClasses' set/queue.
aoqi@0 991 */
aoqi@0 992 void enterInner(ClassSymbol c) {
aoqi@0 993 if (c.type.isCompound()) {
aoqi@0 994 throw new AssertionError("Unexpected intersection type: " + c.type);
aoqi@0 995 }
aoqi@0 996 try {
aoqi@0 997 c.complete();
aoqi@0 998 } catch (CompletionFailure ex) {
aoqi@0 999 System.err.println("error: " + c + ": " + ex.getMessage());
aoqi@0 1000 throw ex;
aoqi@0 1001 }
aoqi@0 1002 if (!c.type.hasTag(CLASS)) return; // arrays
aoqi@0 1003 if (pool != null && // pool might be null if called from xClassName
aoqi@0 1004 c.owner.enclClass() != null &&
aoqi@0 1005 (innerClasses == null || !innerClasses.contains(c))) {
aoqi@0 1006 // log.errWriter.println("enter inner " + c);//DEBUG
aoqi@0 1007 enterInner(c.owner.enclClass());
aoqi@0 1008 pool.put(c);
aoqi@0 1009 if (c.name != names.empty)
aoqi@0 1010 pool.put(c.name);
aoqi@0 1011 if (innerClasses == null) {
aoqi@0 1012 innerClasses = new HashSet<ClassSymbol>();
aoqi@0 1013 innerClassesQueue = new ListBuffer<ClassSymbol>();
aoqi@0 1014 pool.put(names.InnerClasses);
aoqi@0 1015 }
aoqi@0 1016 innerClasses.add(c);
aoqi@0 1017 innerClassesQueue.append(c);
aoqi@0 1018 }
aoqi@0 1019 }
aoqi@0 1020
aoqi@0 1021 /** Write "inner classes" attribute.
aoqi@0 1022 */
aoqi@0 1023 void writeInnerClasses() {
aoqi@0 1024 int alenIdx = writeAttr(names.InnerClasses);
aoqi@0 1025 databuf.appendChar(innerClassesQueue.length());
aoqi@0 1026 for (List<ClassSymbol> l = innerClassesQueue.toList();
aoqi@0 1027 l.nonEmpty();
aoqi@0 1028 l = l.tail) {
aoqi@0 1029 ClassSymbol inner = l.head;
jlahoda@2717 1030 inner.markAbstractIfNeeded(types);
aoqi@0 1031 char flags = (char) adjustFlags(inner.flags_field);
aoqi@0 1032 if ((flags & INTERFACE) != 0) flags |= ABSTRACT; // Interfaces are always ABSTRACT
aoqi@0 1033 if (inner.name.isEmpty()) flags &= ~FINAL; // Anonymous class: unset FINAL flag
aoqi@0 1034 flags &= ~STRICTFP; //inner classes should not have the strictfp flag set.
aoqi@0 1035 if (dumpInnerClassModifiers) {
aoqi@0 1036 PrintWriter pw = log.getWriter(Log.WriterKind.ERROR);
aoqi@0 1037 pw.println("INNERCLASS " + inner.name);
aoqi@0 1038 pw.println("---" + flagNames(flags));
aoqi@0 1039 }
aoqi@0 1040 databuf.appendChar(pool.get(inner));
aoqi@0 1041 databuf.appendChar(
aoqi@0 1042 inner.owner.kind == TYP && !inner.name.isEmpty() ? pool.get(inner.owner) : 0);
aoqi@0 1043 databuf.appendChar(
aoqi@0 1044 !inner.name.isEmpty() ? pool.get(inner.name) : 0);
aoqi@0 1045 databuf.appendChar(flags);
aoqi@0 1046 }
aoqi@0 1047 endAttr(alenIdx);
aoqi@0 1048 }
aoqi@0 1049
aoqi@0 1050 /** Write "bootstrapMethods" attribute.
aoqi@0 1051 */
aoqi@0 1052 void writeBootstrapMethods() {
aoqi@0 1053 int alenIdx = writeAttr(names.BootstrapMethods);
aoqi@0 1054 databuf.appendChar(bootstrapMethods.size());
aoqi@0 1055 for (Map.Entry<DynamicMethod, MethodHandle> entry : bootstrapMethods.entrySet()) {
aoqi@0 1056 DynamicMethod dmeth = entry.getKey();
aoqi@0 1057 DynamicMethodSymbol dsym = (DynamicMethodSymbol)dmeth.baseSymbol();
aoqi@0 1058 //write BSM handle
aoqi@0 1059 databuf.appendChar(pool.get(entry.getValue()));
aoqi@0 1060 //write static args length
aoqi@0 1061 databuf.appendChar(dsym.staticArgs.length);
aoqi@0 1062 //write static args array
aoqi@0 1063 Object[] uniqueArgs = dmeth.uniqueStaticArgs;
aoqi@0 1064 for (Object o : uniqueArgs) {
aoqi@0 1065 databuf.appendChar(pool.get(o));
aoqi@0 1066 }
aoqi@0 1067 }
aoqi@0 1068 endAttr(alenIdx);
aoqi@0 1069 }
aoqi@0 1070
aoqi@0 1071 /** Write field symbol, entering all references into constant pool.
aoqi@0 1072 */
aoqi@0 1073 void writeField(VarSymbol v) {
aoqi@0 1074 int flags = adjustFlags(v.flags());
aoqi@0 1075 databuf.appendChar(flags);
aoqi@0 1076 if (dumpFieldModifiers) {
aoqi@0 1077 PrintWriter pw = log.getWriter(Log.WriterKind.ERROR);
aoqi@0 1078 pw.println("FIELD " + fieldName(v));
aoqi@0 1079 pw.println("---" + flagNames(v.flags()));
aoqi@0 1080 }
aoqi@0 1081 databuf.appendChar(pool.put(fieldName(v)));
aoqi@0 1082 databuf.appendChar(pool.put(typeSig(v.erasure(types))));
aoqi@0 1083 int acountIdx = beginAttrs();
aoqi@0 1084 int acount = 0;
aoqi@0 1085 if (v.getConstValue() != null) {
aoqi@0 1086 int alenIdx = writeAttr(names.ConstantValue);
aoqi@0 1087 databuf.appendChar(pool.put(v.getConstValue()));
aoqi@0 1088 endAttr(alenIdx);
aoqi@0 1089 acount++;
aoqi@0 1090 }
aoqi@0 1091 acount += writeMemberAttrs(v);
aoqi@0 1092 endAttrs(acountIdx, acount);
aoqi@0 1093 }
aoqi@0 1094
aoqi@0 1095 /** Write method symbol, entering all references into constant pool.
aoqi@0 1096 */
aoqi@0 1097 void writeMethod(MethodSymbol m) {
aoqi@0 1098 int flags = adjustFlags(m.flags());
aoqi@0 1099 databuf.appendChar(flags);
aoqi@0 1100 if (dumpMethodModifiers) {
aoqi@0 1101 PrintWriter pw = log.getWriter(Log.WriterKind.ERROR);
aoqi@0 1102 pw.println("METHOD " + fieldName(m));
aoqi@0 1103 pw.println("---" + flagNames(m.flags()));
aoqi@0 1104 }
aoqi@0 1105 databuf.appendChar(pool.put(fieldName(m)));
aoqi@0 1106 databuf.appendChar(pool.put(typeSig(m.externalType(types))));
aoqi@0 1107 int acountIdx = beginAttrs();
aoqi@0 1108 int acount = 0;
aoqi@0 1109 if (m.code != null) {
aoqi@0 1110 int alenIdx = writeAttr(names.Code);
aoqi@0 1111 writeCode(m.code);
aoqi@0 1112 m.code = null; // to conserve space
aoqi@0 1113 endAttr(alenIdx);
aoqi@0 1114 acount++;
aoqi@0 1115 }
aoqi@0 1116 List<Type> thrown = m.erasure(types).getThrownTypes();
aoqi@0 1117 if (thrown.nonEmpty()) {
aoqi@0 1118 int alenIdx = writeAttr(names.Exceptions);
aoqi@0 1119 databuf.appendChar(thrown.length());
aoqi@0 1120 for (List<Type> l = thrown; l.nonEmpty(); l = l.tail)
aoqi@0 1121 databuf.appendChar(pool.put(l.head.tsym));
aoqi@0 1122 endAttr(alenIdx);
aoqi@0 1123 acount++;
aoqi@0 1124 }
aoqi@0 1125 if (m.defaultValue != null) {
aoqi@0 1126 int alenIdx = writeAttr(names.AnnotationDefault);
aoqi@0 1127 m.defaultValue.accept(awriter);
aoqi@0 1128 endAttr(alenIdx);
aoqi@0 1129 acount++;
aoqi@0 1130 }
aoqi@0 1131 if (options.isSet(PARAMETERS))
aoqi@0 1132 acount += writeMethodParametersAttr(m);
aoqi@0 1133 acount += writeMemberAttrs(m);
aoqi@0 1134 acount += writeParameterAttrs(m);
aoqi@0 1135 endAttrs(acountIdx, acount);
aoqi@0 1136 }
aoqi@0 1137
aoqi@0 1138 /** Write code attribute of method.
aoqi@0 1139 */
aoqi@0 1140 void writeCode(Code code) {
aoqi@0 1141 databuf.appendChar(code.max_stack);
aoqi@0 1142 databuf.appendChar(code.max_locals);
aoqi@0 1143 databuf.appendInt(code.cp);
aoqi@0 1144 databuf.appendBytes(code.code, 0, code.cp);
aoqi@0 1145 databuf.appendChar(code.catchInfo.length());
aoqi@0 1146 for (List<char[]> l = code.catchInfo.toList();
aoqi@0 1147 l.nonEmpty();
aoqi@0 1148 l = l.tail) {
aoqi@0 1149 for (int i = 0; i < l.head.length; i++)
aoqi@0 1150 databuf.appendChar(l.head[i]);
aoqi@0 1151 }
aoqi@0 1152 int acountIdx = beginAttrs();
aoqi@0 1153 int acount = 0;
aoqi@0 1154
aoqi@0 1155 if (code.lineInfo.nonEmpty()) {
aoqi@0 1156 int alenIdx = writeAttr(names.LineNumberTable);
aoqi@0 1157 databuf.appendChar(code.lineInfo.length());
aoqi@0 1158 for (List<char[]> l = code.lineInfo.reverse();
aoqi@0 1159 l.nonEmpty();
aoqi@0 1160 l = l.tail)
aoqi@0 1161 for (int i = 0; i < l.head.length; i++)
aoqi@0 1162 databuf.appendChar(l.head[i]);
aoqi@0 1163 endAttr(alenIdx);
aoqi@0 1164 acount++;
aoqi@0 1165 }
aoqi@0 1166
aoqi@0 1167 if (genCrt && (code.crt != null)) {
aoqi@0 1168 CRTable crt = code.crt;
aoqi@0 1169 int alenIdx = writeAttr(names.CharacterRangeTable);
aoqi@0 1170 int crtIdx = beginAttrs();
aoqi@0 1171 int crtEntries = crt.writeCRT(databuf, code.lineMap, log);
aoqi@0 1172 endAttrs(crtIdx, crtEntries);
aoqi@0 1173 endAttr(alenIdx);
aoqi@0 1174 acount++;
aoqi@0 1175 }
aoqi@0 1176
aoqi@0 1177 // counter for number of generic local variables
aoqi@0 1178 if (code.varDebugInfo && code.varBufferSize > 0) {
aoqi@0 1179 int nGenericVars = 0;
aoqi@0 1180 int alenIdx = writeAttr(names.LocalVariableTable);
aoqi@0 1181 databuf.appendChar(code.getLVTSize());
aoqi@0 1182 for (int i=0; i<code.varBufferSize; i++) {
aoqi@0 1183 Code.LocalVar var = code.varBuffer[i];
aoqi@0 1184
aoqi@0 1185 for (Code.LocalVar.Range r: var.aliveRanges) {
aoqi@0 1186 // write variable info
aoqi@0 1187 Assert.check(r.start_pc >= 0
aoqi@0 1188 && r.start_pc <= code.cp);
aoqi@0 1189 databuf.appendChar(r.start_pc);
vromero@2709 1190 Assert.check(r.length > 0
aoqi@0 1191 && (r.start_pc + r.length) <= code.cp);
aoqi@0 1192 databuf.appendChar(r.length);
aoqi@0 1193 VarSymbol sym = var.sym;
aoqi@0 1194 databuf.appendChar(pool.put(sym.name));
aoqi@0 1195 Type vartype = sym.erasure(types);
aoqi@0 1196 databuf.appendChar(pool.put(typeSig(vartype)));
aoqi@0 1197 databuf.appendChar(var.reg);
aoqi@0 1198 if (needsLocalVariableTypeEntry(var.sym.type)) {
aoqi@0 1199 nGenericVars++;
aoqi@0 1200 }
aoqi@0 1201 }
aoqi@0 1202 }
aoqi@0 1203 endAttr(alenIdx);
aoqi@0 1204 acount++;
aoqi@0 1205
aoqi@0 1206 if (nGenericVars > 0) {
aoqi@0 1207 alenIdx = writeAttr(names.LocalVariableTypeTable);
aoqi@0 1208 databuf.appendChar(nGenericVars);
aoqi@0 1209 int count = 0;
aoqi@0 1210
aoqi@0 1211 for (int i=0; i<code.varBufferSize; i++) {
aoqi@0 1212 Code.LocalVar var = code.varBuffer[i];
aoqi@0 1213 VarSymbol sym = var.sym;
aoqi@0 1214 if (!needsLocalVariableTypeEntry(sym.type))
aoqi@0 1215 continue;
aoqi@0 1216 for (Code.LocalVar.Range r : var.aliveRanges) {
aoqi@0 1217 // write variable info
aoqi@0 1218 databuf.appendChar(r.start_pc);
aoqi@0 1219 databuf.appendChar(r.length);
aoqi@0 1220 databuf.appendChar(pool.put(sym.name));
aoqi@0 1221 databuf.appendChar(pool.put(typeSig(sym.type)));
aoqi@0 1222 databuf.appendChar(var.reg);
aoqi@0 1223 count++;
aoqi@0 1224 }
aoqi@0 1225 }
aoqi@0 1226 Assert.check(count == nGenericVars);
aoqi@0 1227 endAttr(alenIdx);
aoqi@0 1228 acount++;
aoqi@0 1229 }
aoqi@0 1230 }
aoqi@0 1231
aoqi@0 1232 if (code.stackMapBufferSize > 0) {
aoqi@0 1233 if (debugstackmap) System.out.println("Stack map for " + code.meth);
aoqi@0 1234 int alenIdx = writeAttr(code.stackMap.getAttributeName(names));
aoqi@0 1235 writeStackMap(code);
aoqi@0 1236 endAttr(alenIdx);
aoqi@0 1237 acount++;
aoqi@0 1238 }
aoqi@0 1239
aoqi@0 1240 acount += writeTypeAnnotations(code.meth.getRawTypeAttributes(), true);
aoqi@0 1241
aoqi@0 1242 endAttrs(acountIdx, acount);
aoqi@0 1243 }
aoqi@0 1244 //where
aoqi@0 1245 private boolean needsLocalVariableTypeEntry(Type t) {
aoqi@0 1246 //a local variable needs a type-entry if its type T is generic
aoqi@0 1247 //(i.e. |T| != T) and if it's not an intersection type (not supported
aoqi@0 1248 //in signature attribute grammar)
aoqi@0 1249 return (!types.isSameType(t, types.erasure(t)) &&
aoqi@0 1250 !t.isCompound());
aoqi@0 1251 }
aoqi@0 1252
aoqi@0 1253 void writeStackMap(Code code) {
aoqi@0 1254 int nframes = code.stackMapBufferSize;
aoqi@0 1255 if (debugstackmap) System.out.println(" nframes = " + nframes);
aoqi@0 1256 databuf.appendChar(nframes);
aoqi@0 1257
aoqi@0 1258 switch (code.stackMap) {
aoqi@0 1259 case CLDC:
aoqi@0 1260 for (int i=0; i<nframes; i++) {
aoqi@0 1261 if (debugstackmap) System.out.print(" " + i + ":");
aoqi@0 1262 Code.StackMapFrame frame = code.stackMapBuffer[i];
aoqi@0 1263
aoqi@0 1264 // output PC
aoqi@0 1265 if (debugstackmap) System.out.print(" pc=" + frame.pc);
aoqi@0 1266 databuf.appendChar(frame.pc);
aoqi@0 1267
aoqi@0 1268 // output locals
aoqi@0 1269 int localCount = 0;
aoqi@0 1270 for (int j=0; j<frame.locals.length;
aoqi@0 1271 j += (target.generateEmptyAfterBig() ? 1 : Code.width(frame.locals[j]))) {
aoqi@0 1272 localCount++;
aoqi@0 1273 }
aoqi@0 1274 if (debugstackmap) System.out.print(" nlocals=" +
aoqi@0 1275 localCount);
aoqi@0 1276 databuf.appendChar(localCount);
aoqi@0 1277 for (int j=0; j<frame.locals.length;
aoqi@0 1278 j += (target.generateEmptyAfterBig() ? 1 : Code.width(frame.locals[j]))) {
aoqi@0 1279 if (debugstackmap) System.out.print(" local[" + j + "]=");
aoqi@0 1280 writeStackMapType(frame.locals[j]);
aoqi@0 1281 }
aoqi@0 1282
aoqi@0 1283 // output stack
aoqi@0 1284 int stackCount = 0;
aoqi@0 1285 for (int j=0; j<frame.stack.length;
aoqi@0 1286 j += (target.generateEmptyAfterBig() ? 1 : Code.width(frame.stack[j]))) {
aoqi@0 1287 stackCount++;
aoqi@0 1288 }
aoqi@0 1289 if (debugstackmap) System.out.print(" nstack=" +
aoqi@0 1290 stackCount);
aoqi@0 1291 databuf.appendChar(stackCount);
aoqi@0 1292 for (int j=0; j<frame.stack.length;
aoqi@0 1293 j += (target.generateEmptyAfterBig() ? 1 : Code.width(frame.stack[j]))) {
aoqi@0 1294 if (debugstackmap) System.out.print(" stack[" + j + "]=");
aoqi@0 1295 writeStackMapType(frame.stack[j]);
aoqi@0 1296 }
aoqi@0 1297 if (debugstackmap) System.out.println();
aoqi@0 1298 }
aoqi@0 1299 break;
aoqi@0 1300 case JSR202: {
aoqi@0 1301 Assert.checkNull(code.stackMapBuffer);
aoqi@0 1302 for (int i=0; i<nframes; i++) {
aoqi@0 1303 if (debugstackmap) System.out.print(" " + i + ":");
aoqi@0 1304 StackMapTableFrame frame = code.stackMapTableBuffer[i];
aoqi@0 1305 frame.write(this);
aoqi@0 1306 if (debugstackmap) System.out.println();
aoqi@0 1307 }
aoqi@0 1308 break;
aoqi@0 1309 }
aoqi@0 1310 default:
aoqi@0 1311 throw new AssertionError("Unexpected stackmap format value");
aoqi@0 1312 }
aoqi@0 1313 }
aoqi@0 1314
aoqi@0 1315 //where
aoqi@0 1316 void writeStackMapType(Type t) {
aoqi@0 1317 if (t == null) {
aoqi@0 1318 if (debugstackmap) System.out.print("empty");
aoqi@0 1319 databuf.appendByte(0);
aoqi@0 1320 }
aoqi@0 1321 else switch(t.getTag()) {
aoqi@0 1322 case BYTE:
aoqi@0 1323 case CHAR:
aoqi@0 1324 case SHORT:
aoqi@0 1325 case INT:
aoqi@0 1326 case BOOLEAN:
aoqi@0 1327 if (debugstackmap) System.out.print("int");
aoqi@0 1328 databuf.appendByte(1);
aoqi@0 1329 break;
aoqi@0 1330 case FLOAT:
aoqi@0 1331 if (debugstackmap) System.out.print("float");
aoqi@0 1332 databuf.appendByte(2);
aoqi@0 1333 break;
aoqi@0 1334 case DOUBLE:
aoqi@0 1335 if (debugstackmap) System.out.print("double");
aoqi@0 1336 databuf.appendByte(3);
aoqi@0 1337 break;
aoqi@0 1338 case LONG:
aoqi@0 1339 if (debugstackmap) System.out.print("long");
aoqi@0 1340 databuf.appendByte(4);
aoqi@0 1341 break;
aoqi@0 1342 case BOT: // null
aoqi@0 1343 if (debugstackmap) System.out.print("null");
aoqi@0 1344 databuf.appendByte(5);
aoqi@0 1345 break;
aoqi@0 1346 case CLASS:
aoqi@0 1347 case ARRAY:
aoqi@0 1348 if (debugstackmap) System.out.print("object(" + t + ")");
aoqi@0 1349 databuf.appendByte(7);
aoqi@0 1350 databuf.appendChar(pool.put(t));
aoqi@0 1351 break;
aoqi@0 1352 case TYPEVAR:
aoqi@0 1353 if (debugstackmap) System.out.print("object(" + types.erasure(t).tsym + ")");
aoqi@0 1354 databuf.appendByte(7);
aoqi@0 1355 databuf.appendChar(pool.put(types.erasure(t).tsym));
aoqi@0 1356 break;
aoqi@0 1357 case UNINITIALIZED_THIS:
aoqi@0 1358 if (debugstackmap) System.out.print("uninit_this");
aoqi@0 1359 databuf.appendByte(6);
aoqi@0 1360 break;
aoqi@0 1361 case UNINITIALIZED_OBJECT:
aoqi@0 1362 { UninitializedType uninitType = (UninitializedType)t;
aoqi@0 1363 databuf.appendByte(8);
aoqi@0 1364 if (debugstackmap) System.out.print("uninit_object@" + uninitType.offset);
aoqi@0 1365 databuf.appendChar(uninitType.offset);
aoqi@0 1366 }
aoqi@0 1367 break;
aoqi@0 1368 default:
aoqi@0 1369 throw new AssertionError();
aoqi@0 1370 }
aoqi@0 1371 }
aoqi@0 1372
aoqi@0 1373 /** An entry in the JSR202 StackMapTable */
aoqi@0 1374 abstract static class StackMapTableFrame {
aoqi@0 1375 abstract int getFrameType();
aoqi@0 1376
aoqi@0 1377 void write(ClassWriter writer) {
aoqi@0 1378 int frameType = getFrameType();
aoqi@0 1379 writer.databuf.appendByte(frameType);
aoqi@0 1380 if (writer.debugstackmap) System.out.print(" frame_type=" + frameType);
aoqi@0 1381 }
aoqi@0 1382
aoqi@0 1383 static class SameFrame extends StackMapTableFrame {
aoqi@0 1384 final int offsetDelta;
aoqi@0 1385 SameFrame(int offsetDelta) {
aoqi@0 1386 this.offsetDelta = offsetDelta;
aoqi@0 1387 }
aoqi@0 1388 int getFrameType() {
aoqi@0 1389 return (offsetDelta < SAME_FRAME_SIZE) ? offsetDelta : SAME_FRAME_EXTENDED;
aoqi@0 1390 }
aoqi@0 1391 @Override
aoqi@0 1392 void write(ClassWriter writer) {
aoqi@0 1393 super.write(writer);
aoqi@0 1394 if (getFrameType() == SAME_FRAME_EXTENDED) {
aoqi@0 1395 writer.databuf.appendChar(offsetDelta);
aoqi@0 1396 if (writer.debugstackmap){
aoqi@0 1397 System.out.print(" offset_delta=" + offsetDelta);
aoqi@0 1398 }
aoqi@0 1399 }
aoqi@0 1400 }
aoqi@0 1401 }
aoqi@0 1402
aoqi@0 1403 static class SameLocals1StackItemFrame extends StackMapTableFrame {
aoqi@0 1404 final int offsetDelta;
aoqi@0 1405 final Type stack;
aoqi@0 1406 SameLocals1StackItemFrame(int offsetDelta, Type stack) {
aoqi@0 1407 this.offsetDelta = offsetDelta;
aoqi@0 1408 this.stack = stack;
aoqi@0 1409 }
aoqi@0 1410 int getFrameType() {
aoqi@0 1411 return (offsetDelta < SAME_FRAME_SIZE) ?
aoqi@0 1412 (SAME_FRAME_SIZE + offsetDelta) :
aoqi@0 1413 SAME_LOCALS_1_STACK_ITEM_EXTENDED;
aoqi@0 1414 }
aoqi@0 1415 @Override
aoqi@0 1416 void write(ClassWriter writer) {
aoqi@0 1417 super.write(writer);
aoqi@0 1418 if (getFrameType() == SAME_LOCALS_1_STACK_ITEM_EXTENDED) {
aoqi@0 1419 writer.databuf.appendChar(offsetDelta);
aoqi@0 1420 if (writer.debugstackmap) {
aoqi@0 1421 System.out.print(" offset_delta=" + offsetDelta);
aoqi@0 1422 }
aoqi@0 1423 }
aoqi@0 1424 if (writer.debugstackmap) {
aoqi@0 1425 System.out.print(" stack[" + 0 + "]=");
aoqi@0 1426 }
aoqi@0 1427 writer.writeStackMapType(stack);
aoqi@0 1428 }
aoqi@0 1429 }
aoqi@0 1430
aoqi@0 1431 static class ChopFrame extends StackMapTableFrame {
aoqi@0 1432 final int frameType;
aoqi@0 1433 final int offsetDelta;
aoqi@0 1434 ChopFrame(int frameType, int offsetDelta) {
aoqi@0 1435 this.frameType = frameType;
aoqi@0 1436 this.offsetDelta = offsetDelta;
aoqi@0 1437 }
aoqi@0 1438 int getFrameType() { return frameType; }
aoqi@0 1439 @Override
aoqi@0 1440 void write(ClassWriter writer) {
aoqi@0 1441 super.write(writer);
aoqi@0 1442 writer.databuf.appendChar(offsetDelta);
aoqi@0 1443 if (writer.debugstackmap) {
aoqi@0 1444 System.out.print(" offset_delta=" + offsetDelta);
aoqi@0 1445 }
aoqi@0 1446 }
aoqi@0 1447 }
aoqi@0 1448
aoqi@0 1449 static class AppendFrame extends StackMapTableFrame {
aoqi@0 1450 final int frameType;
aoqi@0 1451 final int offsetDelta;
aoqi@0 1452 final Type[] locals;
aoqi@0 1453 AppendFrame(int frameType, int offsetDelta, Type[] locals) {
aoqi@0 1454 this.frameType = frameType;
aoqi@0 1455 this.offsetDelta = offsetDelta;
aoqi@0 1456 this.locals = locals;
aoqi@0 1457 }
aoqi@0 1458 int getFrameType() { return frameType; }
aoqi@0 1459 @Override
aoqi@0 1460 void write(ClassWriter writer) {
aoqi@0 1461 super.write(writer);
aoqi@0 1462 writer.databuf.appendChar(offsetDelta);
aoqi@0 1463 if (writer.debugstackmap) {
aoqi@0 1464 System.out.print(" offset_delta=" + offsetDelta);
aoqi@0 1465 }
aoqi@0 1466 for (int i=0; i<locals.length; i++) {
aoqi@0 1467 if (writer.debugstackmap) System.out.print(" locals[" + i + "]=");
aoqi@0 1468 writer.writeStackMapType(locals[i]);
aoqi@0 1469 }
aoqi@0 1470 }
aoqi@0 1471 }
aoqi@0 1472
aoqi@0 1473 static class FullFrame extends StackMapTableFrame {
aoqi@0 1474 final int offsetDelta;
aoqi@0 1475 final Type[] locals;
aoqi@0 1476 final Type[] stack;
aoqi@0 1477 FullFrame(int offsetDelta, Type[] locals, Type[] stack) {
aoqi@0 1478 this.offsetDelta = offsetDelta;
aoqi@0 1479 this.locals = locals;
aoqi@0 1480 this.stack = stack;
aoqi@0 1481 }
aoqi@0 1482 int getFrameType() { return FULL_FRAME; }
aoqi@0 1483 @Override
aoqi@0 1484 void write(ClassWriter writer) {
aoqi@0 1485 super.write(writer);
aoqi@0 1486 writer.databuf.appendChar(offsetDelta);
aoqi@0 1487 writer.databuf.appendChar(locals.length);
aoqi@0 1488 if (writer.debugstackmap) {
aoqi@0 1489 System.out.print(" offset_delta=" + offsetDelta);
aoqi@0 1490 System.out.print(" nlocals=" + locals.length);
aoqi@0 1491 }
aoqi@0 1492 for (int i=0; i<locals.length; i++) {
aoqi@0 1493 if (writer.debugstackmap) System.out.print(" locals[" + i + "]=");
aoqi@0 1494 writer.writeStackMapType(locals[i]);
aoqi@0 1495 }
aoqi@0 1496
aoqi@0 1497 writer.databuf.appendChar(stack.length);
aoqi@0 1498 if (writer.debugstackmap) { System.out.print(" nstack=" + stack.length); }
aoqi@0 1499 for (int i=0; i<stack.length; i++) {
aoqi@0 1500 if (writer.debugstackmap) System.out.print(" stack[" + i + "]=");
aoqi@0 1501 writer.writeStackMapType(stack[i]);
aoqi@0 1502 }
aoqi@0 1503 }
aoqi@0 1504 }
aoqi@0 1505
aoqi@0 1506 /** Compare this frame with the previous frame and produce
aoqi@0 1507 * an entry of compressed stack map frame. */
aoqi@0 1508 static StackMapTableFrame getInstance(Code.StackMapFrame this_frame,
aoqi@0 1509 int prev_pc,
aoqi@0 1510 Type[] prev_locals,
aoqi@0 1511 Types types) {
aoqi@0 1512 Type[] locals = this_frame.locals;
aoqi@0 1513 Type[] stack = this_frame.stack;
aoqi@0 1514 int offset_delta = this_frame.pc - prev_pc - 1;
aoqi@0 1515 if (stack.length == 1) {
aoqi@0 1516 if (locals.length == prev_locals.length
aoqi@0 1517 && compare(prev_locals, locals, types) == 0) {
aoqi@0 1518 return new SameLocals1StackItemFrame(offset_delta, stack[0]);
aoqi@0 1519 }
aoqi@0 1520 } else if (stack.length == 0) {
aoqi@0 1521 int diff_length = compare(prev_locals, locals, types);
aoqi@0 1522 if (diff_length == 0) {
aoqi@0 1523 return new SameFrame(offset_delta);
aoqi@0 1524 } else if (-MAX_LOCAL_LENGTH_DIFF < diff_length && diff_length < 0) {
aoqi@0 1525 // APPEND
aoqi@0 1526 Type[] local_diff = new Type[-diff_length];
aoqi@0 1527 for (int i=prev_locals.length, j=0; i<locals.length; i++,j++) {
aoqi@0 1528 local_diff[j] = locals[i];
aoqi@0 1529 }
aoqi@0 1530 return new AppendFrame(SAME_FRAME_EXTENDED - diff_length,
aoqi@0 1531 offset_delta,
aoqi@0 1532 local_diff);
aoqi@0 1533 } else if (0 < diff_length && diff_length < MAX_LOCAL_LENGTH_DIFF) {
aoqi@0 1534 // CHOP
aoqi@0 1535 return new ChopFrame(SAME_FRAME_EXTENDED - diff_length,
aoqi@0 1536 offset_delta);
aoqi@0 1537 }
aoqi@0 1538 }
aoqi@0 1539 // FULL_FRAME
aoqi@0 1540 return new FullFrame(offset_delta, locals, stack);
aoqi@0 1541 }
aoqi@0 1542
aoqi@0 1543 static boolean isInt(Type t) {
aoqi@0 1544 return (t.getTag().isStrictSubRangeOf(INT) || t.hasTag(BOOLEAN));
aoqi@0 1545 }
aoqi@0 1546
aoqi@0 1547 static boolean isSameType(Type t1, Type t2, Types types) {
aoqi@0 1548 if (t1 == null) { return t2 == null; }
aoqi@0 1549 if (t2 == null) { return false; }
aoqi@0 1550
aoqi@0 1551 if (isInt(t1) && isInt(t2)) { return true; }
aoqi@0 1552
aoqi@0 1553 if (t1.hasTag(UNINITIALIZED_THIS)) {
aoqi@0 1554 return t2.hasTag(UNINITIALIZED_THIS);
aoqi@0 1555 } else if (t1.hasTag(UNINITIALIZED_OBJECT)) {
aoqi@0 1556 if (t2.hasTag(UNINITIALIZED_OBJECT)) {
aoqi@0 1557 return ((UninitializedType)t1).offset == ((UninitializedType)t2).offset;
aoqi@0 1558 } else {
aoqi@0 1559 return false;
aoqi@0 1560 }
aoqi@0 1561 } else if (t2.hasTag(UNINITIALIZED_THIS) || t2.hasTag(UNINITIALIZED_OBJECT)) {
aoqi@0 1562 return false;
aoqi@0 1563 }
aoqi@0 1564
aoqi@0 1565 return types.isSameType(t1, t2);
aoqi@0 1566 }
aoqi@0 1567
aoqi@0 1568 static int compare(Type[] arr1, Type[] arr2, Types types) {
aoqi@0 1569 int diff_length = arr1.length - arr2.length;
aoqi@0 1570 if (diff_length > MAX_LOCAL_LENGTH_DIFF || diff_length < -MAX_LOCAL_LENGTH_DIFF) {
aoqi@0 1571 return Integer.MAX_VALUE;
aoqi@0 1572 }
aoqi@0 1573 int len = (diff_length > 0) ? arr2.length : arr1.length;
aoqi@0 1574 for (int i=0; i<len; i++) {
aoqi@0 1575 if (!isSameType(arr1[i], arr2[i], types)) {
aoqi@0 1576 return Integer.MAX_VALUE;
aoqi@0 1577 }
aoqi@0 1578 }
aoqi@0 1579 return diff_length;
aoqi@0 1580 }
aoqi@0 1581 }
aoqi@0 1582
aoqi@0 1583 void writeFields(Scope.Entry e) {
aoqi@0 1584 // process them in reverse sibling order;
aoqi@0 1585 // i.e., process them in declaration order.
aoqi@0 1586 List<VarSymbol> vars = List.nil();
aoqi@0 1587 for (Scope.Entry i = e; i != null; i = i.sibling) {
aoqi@0 1588 if (i.sym.kind == VAR) vars = vars.prepend((VarSymbol)i.sym);
aoqi@0 1589 }
aoqi@0 1590 while (vars.nonEmpty()) {
aoqi@0 1591 writeField(vars.head);
aoqi@0 1592 vars = vars.tail;
aoqi@0 1593 }
aoqi@0 1594 }
aoqi@0 1595
aoqi@0 1596 void writeMethods(Scope.Entry e) {
aoqi@0 1597 List<MethodSymbol> methods = List.nil();
aoqi@0 1598 for (Scope.Entry i = e; i != null; i = i.sibling) {
aoqi@0 1599 if (i.sym.kind == MTH && (i.sym.flags() & HYPOTHETICAL) == 0)
aoqi@0 1600 methods = methods.prepend((MethodSymbol)i.sym);
aoqi@0 1601 }
aoqi@0 1602 while (methods.nonEmpty()) {
aoqi@0 1603 writeMethod(methods.head);
aoqi@0 1604 methods = methods.tail;
aoqi@0 1605 }
aoqi@0 1606 }
aoqi@0 1607
aoqi@0 1608 /** Emit a class file for a given class.
aoqi@0 1609 * @param c The class from which a class file is generated.
aoqi@0 1610 */
aoqi@0 1611 public JavaFileObject writeClass(ClassSymbol c)
aoqi@0 1612 throws IOException, PoolOverflow, StringOverflow
aoqi@0 1613 {
aoqi@0 1614 JavaFileObject outFile
aoqi@0 1615 = fileManager.getJavaFileForOutput(CLASS_OUTPUT,
aoqi@0 1616 c.flatname.toString(),
aoqi@0 1617 JavaFileObject.Kind.CLASS,
aoqi@0 1618 c.sourcefile);
aoqi@0 1619 OutputStream out = outFile.openOutputStream();
aoqi@0 1620 try {
aoqi@0 1621 writeClassFile(out, c);
aoqi@0 1622 if (verbose)
aoqi@0 1623 log.printVerbose("wrote.file", outFile);
aoqi@0 1624 out.close();
aoqi@0 1625 out = null;
aoqi@0 1626 } finally {
aoqi@0 1627 if (out != null) {
aoqi@0 1628 // if we are propagating an exception, delete the file
aoqi@0 1629 out.close();
aoqi@0 1630 outFile.delete();
aoqi@0 1631 outFile = null;
aoqi@0 1632 }
aoqi@0 1633 }
aoqi@0 1634 return outFile; // may be null if write failed
aoqi@0 1635 }
aoqi@0 1636
aoqi@0 1637 /** Write class `c' to outstream `out'.
aoqi@0 1638 */
aoqi@0 1639 public void writeClassFile(OutputStream out, ClassSymbol c)
aoqi@0 1640 throws IOException, PoolOverflow, StringOverflow {
aoqi@0 1641 Assert.check((c.flags() & COMPOUND) == 0);
aoqi@0 1642 databuf.reset();
aoqi@0 1643 poolbuf.reset();
aoqi@0 1644 signatureGen.reset();
aoqi@0 1645 pool = c.pool;
aoqi@0 1646 innerClasses = null;
aoqi@0 1647 innerClassesQueue = null;
aoqi@0 1648 bootstrapMethods = new LinkedHashMap<DynamicMethod, MethodHandle>();
aoqi@0 1649
aoqi@0 1650 Type supertype = types.supertype(c.type);
aoqi@0 1651 List<Type> interfaces = types.interfaces(c.type);
aoqi@0 1652 List<Type> typarams = c.type.getTypeArguments();
aoqi@0 1653
aoqi@0 1654 int flags = adjustFlags(c.flags() & ~DEFAULT);
aoqi@0 1655 if ((flags & PROTECTED) != 0) flags |= PUBLIC;
aoqi@0 1656 flags = flags & ClassFlags & ~STRICTFP;
aoqi@0 1657 if ((flags & INTERFACE) == 0) flags |= ACC_SUPER;
aoqi@0 1658 if (c.isInner() && c.name.isEmpty()) flags &= ~FINAL;
aoqi@0 1659 if (dumpClassModifiers) {
aoqi@0 1660 PrintWriter pw = log.getWriter(Log.WriterKind.ERROR);
aoqi@0 1661 pw.println();
aoqi@0 1662 pw.println("CLASSFILE " + c.getQualifiedName());
aoqi@0 1663 pw.println("---" + flagNames(flags));
aoqi@0 1664 }
aoqi@0 1665 databuf.appendChar(flags);
aoqi@0 1666
aoqi@0 1667 databuf.appendChar(pool.put(c));
aoqi@0 1668 databuf.appendChar(supertype.hasTag(CLASS) ? pool.put(supertype.tsym) : 0);
aoqi@0 1669 databuf.appendChar(interfaces.length());
aoqi@0 1670 for (List<Type> l = interfaces; l.nonEmpty(); l = l.tail)
aoqi@0 1671 databuf.appendChar(pool.put(l.head.tsym));
aoqi@0 1672 int fieldsCount = 0;
aoqi@0 1673 int methodsCount = 0;
aoqi@0 1674 for (Scope.Entry e = c.members().elems; e != null; e = e.sibling) {
aoqi@0 1675 switch (e.sym.kind) {
aoqi@0 1676 case VAR: fieldsCount++; break;
aoqi@0 1677 case MTH: if ((e.sym.flags() & HYPOTHETICAL) == 0) methodsCount++;
aoqi@0 1678 break;
aoqi@0 1679 case TYP: enterInner((ClassSymbol)e.sym); break;
aoqi@0 1680 default : Assert.error();
aoqi@0 1681 }
aoqi@0 1682 }
aoqi@0 1683
aoqi@0 1684 if (c.trans_local != null) {
aoqi@0 1685 for (ClassSymbol local : c.trans_local) {
aoqi@0 1686 enterInner(local);
aoqi@0 1687 }
aoqi@0 1688 }
aoqi@0 1689
aoqi@0 1690 databuf.appendChar(fieldsCount);
aoqi@0 1691 writeFields(c.members().elems);
aoqi@0 1692 databuf.appendChar(methodsCount);
aoqi@0 1693 writeMethods(c.members().elems);
aoqi@0 1694
aoqi@0 1695 int acountIdx = beginAttrs();
aoqi@0 1696 int acount = 0;
aoqi@0 1697
aoqi@0 1698 boolean sigReq =
aoqi@0 1699 typarams.length() != 0 || supertype.allparams().length() != 0;
aoqi@0 1700 for (List<Type> l = interfaces; !sigReq && l.nonEmpty(); l = l.tail)
aoqi@0 1701 sigReq = l.head.allparams().length() != 0;
aoqi@0 1702 if (sigReq) {
aoqi@0 1703 Assert.check(source.allowGenerics());
aoqi@0 1704 int alenIdx = writeAttr(names.Signature);
aoqi@0 1705 if (typarams.length() != 0) signatureGen.assembleParamsSig(typarams);
aoqi@0 1706 signatureGen.assembleSig(supertype);
aoqi@0 1707 for (List<Type> l = interfaces; l.nonEmpty(); l = l.tail)
aoqi@0 1708 signatureGen.assembleSig(l.head);
aoqi@0 1709 databuf.appendChar(pool.put(signatureGen.toName()));
aoqi@0 1710 signatureGen.reset();
aoqi@0 1711 endAttr(alenIdx);
aoqi@0 1712 acount++;
aoqi@0 1713 }
aoqi@0 1714
aoqi@0 1715 if (c.sourcefile != null && emitSourceFile) {
aoqi@0 1716 int alenIdx = writeAttr(names.SourceFile);
aoqi@0 1717 // WHM 6/29/1999: Strip file path prefix. We do it here at
aoqi@0 1718 // the last possible moment because the sourcefile may be used
aoqi@0 1719 // elsewhere in error diagnostics. Fixes 4241573.
aoqi@0 1720 //databuf.appendChar(c.pool.put(c.sourcefile));
aoqi@0 1721 String simpleName = BaseFileObject.getSimpleName(c.sourcefile);
aoqi@0 1722 databuf.appendChar(c.pool.put(names.fromString(simpleName)));
aoqi@0 1723 endAttr(alenIdx);
aoqi@0 1724 acount++;
aoqi@0 1725 }
aoqi@0 1726
aoqi@0 1727 if (genCrt) {
aoqi@0 1728 // Append SourceID attribute
aoqi@0 1729 int alenIdx = writeAttr(names.SourceID);
aoqi@0 1730 databuf.appendChar(c.pool.put(names.fromString(Long.toString(getLastModified(c.sourcefile)))));
aoqi@0 1731 endAttr(alenIdx);
aoqi@0 1732 acount++;
aoqi@0 1733 // Append CompilationID attribute
aoqi@0 1734 alenIdx = writeAttr(names.CompilationID);
aoqi@0 1735 databuf.appendChar(c.pool.put(names.fromString(Long.toString(System.currentTimeMillis()))));
aoqi@0 1736 endAttr(alenIdx);
aoqi@0 1737 acount++;
aoqi@0 1738 }
aoqi@0 1739
aoqi@0 1740 acount += writeFlagAttrs(c.flags());
aoqi@0 1741 acount += writeJavaAnnotations(c.getRawAttributes());
aoqi@0 1742 acount += writeTypeAnnotations(c.getRawTypeAttributes(), false);
aoqi@0 1743 acount += writeEnclosingMethodAttribute(c);
aoqi@0 1744 acount += writeExtraClassAttributes(c);
aoqi@0 1745
aoqi@0 1746 poolbuf.appendInt(JAVA_MAGIC);
aoqi@0 1747 poolbuf.appendChar(target.minorVersion);
aoqi@0 1748 poolbuf.appendChar(target.majorVersion);
aoqi@0 1749
aoqi@0 1750 writePool(c.pool);
aoqi@0 1751
aoqi@0 1752 if (innerClasses != null) {
aoqi@0 1753 writeInnerClasses();
aoqi@0 1754 acount++;
aoqi@0 1755 }
aoqi@0 1756
aoqi@0 1757 if (!bootstrapMethods.isEmpty()) {
aoqi@0 1758 writeBootstrapMethods();
aoqi@0 1759 acount++;
aoqi@0 1760 }
aoqi@0 1761
aoqi@0 1762 endAttrs(acountIdx, acount);
aoqi@0 1763
aoqi@0 1764 poolbuf.appendBytes(databuf.elems, 0, databuf.length);
aoqi@0 1765 out.write(poolbuf.elems, 0, poolbuf.length);
aoqi@0 1766
aoqi@0 1767 pool = c.pool = null; // to conserve space
aoqi@0 1768 }
aoqi@0 1769
aoqi@0 1770 /**Allows subclasses to write additional class attributes
aoqi@0 1771 *
aoqi@0 1772 * @return the number of attributes written
aoqi@0 1773 */
aoqi@0 1774 protected int writeExtraClassAttributes(ClassSymbol c) {
aoqi@0 1775 return 0;
aoqi@0 1776 }
aoqi@0 1777
aoqi@0 1778 int adjustFlags(final long flags) {
aoqi@0 1779 int result = (int)flags;
aoqi@0 1780 if ((flags & SYNTHETIC) != 0 && !target.useSyntheticFlag())
aoqi@0 1781 result &= ~SYNTHETIC;
aoqi@0 1782 if ((flags & ENUM) != 0 && !target.useEnumFlag())
aoqi@0 1783 result &= ~ENUM;
aoqi@0 1784 if ((flags & ANNOTATION) != 0 && !target.useAnnotationFlag())
aoqi@0 1785 result &= ~ANNOTATION;
aoqi@0 1786
aoqi@0 1787 if ((flags & BRIDGE) != 0 && target.useBridgeFlag())
aoqi@0 1788 result |= ACC_BRIDGE;
aoqi@0 1789 if ((flags & VARARGS) != 0 && target.useVarargsFlag())
aoqi@0 1790 result |= ACC_VARARGS;
aoqi@0 1791 if ((flags & DEFAULT) != 0)
aoqi@0 1792 result &= ~ABSTRACT;
aoqi@0 1793 return result;
aoqi@0 1794 }
aoqi@0 1795
aoqi@0 1796 long getLastModified(FileObject filename) {
aoqi@0 1797 long mod = 0;
aoqi@0 1798 try {
aoqi@0 1799 mod = filename.getLastModified();
aoqi@0 1800 } catch (SecurityException e) {
aoqi@0 1801 throw new AssertionError("CRT: couldn't get source file modification date: " + e.getMessage());
aoqi@0 1802 }
aoqi@0 1803 return mod;
aoqi@0 1804 }
aoqi@0 1805 }

mercurial