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

changeset 804
3131e664558d
parent 795
7b99f98b3035
child 809
e63b1f8341ce
     1.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Wed Dec 15 06:39:51 2010 -0800
     1.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Sat Dec 18 09:38:39 2010 -0800
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -77,6 +77,8 @@
    1.11      protected static final Context.Key<ClassReader> classReaderKey =
    1.12          new Context.Key<ClassReader>();
    1.13  
    1.14 +    public static final int INITIAL_BUFFER_SIZE = 0x0fff0;
    1.15 +
    1.16      Annotate annotate;
    1.17  
    1.18      /** Switch: verbose output.
    1.19 @@ -185,7 +187,7 @@
    1.20  
    1.21      /** The buffer containing the currently read class file.
    1.22       */
    1.23 -    byte[] buf = new byte[0x0fff0];
    1.24 +    byte[] buf = new byte[INITIAL_BUFFER_SIZE];
    1.25  
    1.26      /** The current input pointer.
    1.27       */
    1.28 @@ -2419,8 +2421,14 @@
    1.29                  }
    1.30              }
    1.31          }
    1.32 +        /*
    1.33 +         * ensureCapacity will increase the buffer as needed, taking note that
    1.34 +         * the new buffer will always be greater than the needed and never
    1.35 +         * exactly equal to the needed size or bp. If equal then the read (above)
    1.36 +         * will infinitely loop as buf.length - bp == 0.
    1.37 +         */
    1.38          private static byte[] ensureCapacity(byte[] buf, int needed) {
    1.39 -            if (buf.length < needed) {
    1.40 +            if (buf.length <= needed) {
    1.41                  byte[] old = buf;
    1.42                  buf = new byte[Integer.highestOneBit(needed) << 1];
    1.43                  System.arraycopy(old, 0, buf, 0, old.length);

mercurial