Changeset 15359


Ignore:
Timestamp:
07/30/20 14:09:13 (3 years ago)
Author:
Mark Evenson
Message:

Fix running openjdk11 compilation on openjdk8

Seemingly, the openjdk11 compiler optimizes the call to
java.nio.Buffer.flip() in to be directly on the java.nio.ByteBuffer?
type. We fixed other instances of java.nio.Buffer interfaces to the
point of being able to run the ANSI-TEST suite.

This caused errors such as:

Exception in thread "interpreter" java.lang.NoSuchMethodError?: java.nio.ByteBuffer?.flip()Ljava/nio/ByteBuffer;
at org.armedbear.lisp.util.DecodingReader?.<init>(DecodingReader?.java:87)
at org.armedbear.lisp.Stream.<init>(Stream.java:165)
at org.armedbear.lisp.Stream.<init>(Stream.java:148)

Location:
trunk/abcl/src/org/armedbear/lisp
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/BasicVector_ByteBuffer.java

    r15350 r15359  
    8888    elements = buffer;
    8989    this.directAllocation = directAllocation;
    90     capacity = buffer.limit(); 
     90    capacity = ((java.nio.Buffer)buffer).limit(); 
    9191  }
    9292
     
    156156      return (((int)elements.get(index) & 0xff)); // XXX Hmmm
    157157    } catch (IndexOutOfBoundsException e) {
    158       badIndex(index, elements.limit());
     158      badIndex(index, ((java.nio.Buffer)elements).limit());
    159159      // Not reached.
    160160      return 0;
     
    167167      return coerceFromJavaByte(elements.get(index));
    168168    } catch (IndexOutOfBoundsException e) {
    169       badIndex(index, elements.limit());
     169      badIndex(index, ((java.nio.Buffer)elements).limit());
    170170      return NIL; // Not reached.
    171171    }
     
    195195    BasicVector_ByteBuffer v = new BasicVector_ByteBuffer(end - start, directAllocation);
    196196    ByteBuffer view = elements.asReadOnlyBuffer();
    197     view.position(start);
    198     view.limit(end);
     197    ((java.nio.Buffer)view).position(start);
     198    ((java.nio.Buffer)view).limit(end);
    199199    try {
    200200      v.elements.put(view);
     
    231231    // this strategy will work out

    232232    if (n < length()) {
    233         elements.limit(n);
     233        ((java.nio.Buffer)elements).limit(n);
    234234        capacity = n;
    235235        return;
  • trunk/abcl/src/org/armedbear/lisp/BasicVector_CharBuffer.java

    r15305 r15359  
    7777    elements = buffer.asCharBuffer();
    7878    this.directAllocation = directAllocation;
    79     capacity = buffer.limit();
     79    capacity = ((java.nio.Buffer)buffer).limit();
    8080  }
    8181
     
    8383    elements = buffer;
    8484    this.directAllocation = directAllocation;
    85     capacity = buffer.limit();
     85    capacity = ((java.nio.Buffer)buffer).limit();
    8686  }
    8787
     
    152152      return elements.get(index);
    153153    } catch (ArrayIndexOutOfBoundsException e) {
    154       badIndex(index, elements.limit()); // FIXME should implement method for length() contract
     154      badIndex(index, ((java.nio.Buffer)elements).limit()); // FIXME should implement method for length() contract
    155155      // Not reached.
    156156      return 0;
     
    164164      return Fixnum.getInstance(elements.get(index));
    165165    } catch (IndexOutOfBoundsException e) {
    166       badIndex(index, elements.limit());  // FIXME limit() --> capacity?
     166      badIndex(index, ((java.nio.Buffer)elements).limit());  // FIXME limit() --> capacity?
    167167      return NIL; // Not reached.
    168168    }
     
    231231    // Not totally sure that this strategy will work out

    232232    if (n < length()) {
    233       elements.limit(n);
     233      ((java.nio.Buffer)elements).limit(n);
    234234      capacity = n;
    235235      return;
  • trunk/abcl/src/org/armedbear/lisp/BasicVector_IntBuffer.java

    r15337 r15359  
    8080    this.directAllocation = directAllocation;
    8181    elements = buffer.asIntBuffer();
    82     capacity = buffer.limit();
     82    capacity = ((java.nio.Buffer)buffer).limit();
    8383  }
    8484
     
    8686    this.directAllocation = directAllocation;
    8787    elements = buffer;
    88     capacity = buffer.limit();
     88    capacity = ((java.nio.Buffer)buffer).limit();
    8989  }
    9090
     
    155155      return number(((long)elements.get(index)) & 0xffffffffL).intValue();
    156156    } catch (IndexOutOfBoundsException e) {
    157       badIndex(index, elements.limit());
     157      badIndex(index, ((java.nio.Buffer)elements).limit());
    158158      return -1; // Not reached.
    159159    }
     
    165165      return ((long)elements.get(index)) & 0xffffffffL;
    166166    } catch (IndexOutOfBoundsException e) {
    167       badIndex(index, elements.limit());
     167      badIndex(index, ((java.nio.Buffer)elements).limit());
    168168      return -1; // Not reached.
    169169    }
     
    175175      return number(((long)elements.get(index)) & 0xffffffffL);
    176176    } catch (IndexOutOfBoundsException e) {
    177       badIndex(index, elements.limit());
     177      badIndex(index, ((java.nio.Buffer)elements).limit());
    178178      return NIL; // Not reached.
    179179    }
     
    229229      // shouldn't touch, so use the java.nio.Buffer limit pointer.
    230230      // Not totally sure that this strategy will work out

    231       elements.limit(n);
     231      ((java.nio.Buffer)elements).limit(n);
    232232      capacity = n;
    233233      return;
  • trunk/abcl/src/org/armedbear/lisp/ComplexArray_ByteBuffer.java

    r15350 r15359  
    250250    }
    251251    if (data != null) {
    252       for (int i = data.limit(); i-- > 0;)
     252      for (int i = ((java.nio.Buffer)data).limit(); i-- > 0;)
    253253        data.put(i, (byte) n); // FIXME Faster!!
    254254    } else {
     
    279279  // FIXME move me to someplace more general
    280280  public static void fill(ByteBuffer buffer, byte value) {
    281     for (int i = 0; i < buffer.limit(); i++) {
     281    for (int i = 0; i < ((java.nio.Buffer)buffer).limit(); i++) {
    282282      buffer.put(value);
    283283    }
  • trunk/abcl/src/org/armedbear/lisp/ComplexArray_IntBuffer.java

    r15351 r15359  
    240240    }
    241241    if (data != null) {
    242       for (int i = data.limit(); i-- > 0;) {
     242      for (int i = ((java.nio.Buffer)data).limit(); i-- > 0;) {
    243243        data.put(i, (int) (obj.longValue() & 0xffffffffL));;
    244244      }
  • trunk/abcl/src/org/armedbear/lisp/ComplexVector_ByteBuffer.java

    r15350 r15359  
    192192        return coerceFromJavaByte(elements.get(index));
    193193      } catch (ArrayIndexOutOfBoundsException e) {
    194         badIndex(index, elements.limit());
     194        badIndex(index, ((java.nio.Buffer)elements).limit());
    195195        return NIL; // Not reached.
    196196      }
     
    229229        elements.put(index, coerceToJavaByte(newValue));
    230230      } catch (IndexOutOfBoundsException e) {
    231         badIndex(index, elements.limit());
     231        badIndex(index, ((java.nio.Buffer)elements).limit());
    232232      }
    233233    } else {
     
    273273    // use the limit marker to denote the length
    274274    if (n < length()) {
    275       elements.limit(n);
     275      ((java.nio.Buffer)elements).limit(n);
    276276      this.capacity = n;
    277277      return;
    278278    }
    279     if (n == elements.limit()) {
     279    if (n == ((java.nio.Buffer)elements).limit()) {
    280280      return;
    281281    }
  • trunk/abcl/src/org/armedbear/lisp/ComplexVector_IntBuffer.java

    r15351 r15359  
    185185        return number(((long)elements.get(index)) & 0xffffffffL);
    186186      } catch (IndexOutOfBoundsException e) {
    187         badIndex(index, elements.limit());
     187        badIndex(index, ((java.nio.Buffer)elements).limit());
    188188        return NIL; // Not reached.
    189189      }
     
    207207        elements.put(index, (int)(newValue.longValue() & 0xffffffffL));
    208208      } catch (IndexOutOfBoundsException e) {
    209         badIndex(index, elements.limit());
     209        badIndex(index, ((java.nio.Buffer)elements).limit());
    210210      }
    211211    } else {
     
    253253    // use the limit marker to denote the length
    254254    if (n < length()) {
    255       elements.limit(n);
     255      ((java.nio.Buffer)elements).limit(n);
    256256      this.capacity = n;
    257257      return;
    258258    }
    259     if (n == elements.limit()) {
     259    if (n == ((java.nio.Buffer)elements).limit()) {
    260260      return;
    261261    }
  • trunk/abcl/src/org/armedbear/lisp/util/DecodingReader.java

    r12902 r15359  
    8585        this.ce = cs.newEncoder();
    8686        bbuf = ByteBuffer.allocate(size);
    87         bbuf.flip();  // mark the buffer as 'needs refill'
     87        ((java.nio.Buffer)bbuf).flip();  // mark the buffer as 'needs refill'
    8888    }
    8989
     
    174174            ce.encode(CharBuffer.wrap(cbuf, off, len));
    175175
    176         if (tb.limit() > bbuf.position()) {
     176        if (tb.limit() > ((java.nio.Buffer)bbuf).position()) {
    177177            // unread bbuf into the pushback input stream
    178178            // in order to free up space for the content of 'tb'
    179             for (int i = bbuf.limit(); i-- > bbuf.position(); )
     179      for (int i = ((java.nio.Buffer)bbuf).limit(); i-- > ((java.nio.Buffer)bbuf).position(); )
    180180                stream.unread(bbuf.get(i));
    181181
    182             bbuf.clear();
     182            ((java.nio.Buffer)bbuf).clear();
    183183            ce.encode(CharBuffer.wrap(cbuf, off, len), bbuf, true);
    184             bbuf.flip();
     184            ((java.nio.Buffer)bbuf).flip();
    185185        } else {
    186186            // Don't unread bbuf, since tb will fit in front of the
    187187            // existing data
    188             int j = bbuf.position() - 1;
    189             for (int i = tb.limit(); i-- > 0; j--) // two-counter loop
     188    int j = ((java.nio.Buffer)bbuf).position() - 1;
     189            for (int i = ((java.nio.Buffer)tb).limit(); i-- > 0; j--) // two-counter loop
    190190                bbuf.put(j, tb.get(i));
    191191
    192             bbuf.position(j+1);
     192            ((java.nio.Buffer)bbuf).position(j+1);
    193193        }
    194194    }
     
    215215
    216216            if (c < 0) {
    217                 bbuf.flip();  // prepare bbuf for reading
     217          ((java.nio.Buffer)bbuf).flip();  // prepare bbuf for reading
    218218                return false;
    219219            }
    220220
    221221            bbuf.put(by, 0, c);
    222             bbuf.flip();
     222            ((java.nio.Buffer)bbuf).flip();
    223223        }
    224224        return true;
  • trunk/abcl/src/org/armedbear/lisp/util/RandomAccessCharacterFile.java

    r14863 r15359  
    1818 * You should have received a copy of the GNU General Public License
    1919 * along with this program; if not, write to the Free Software
    20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
     20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, .
    2121 *
    2222 * As a special exception, the copyright holders of this library give you
     
    297297
    298298        // there is no readable data available in the buffers.
    299         bbuf.flip();
     299        ((java.nio.Buffer)bbuf).flip();
    300300
    301301        // there is no write pending data in the buffers.
     
    361361            if (bbufIsDirty) {
    362362                flushBbuf(false);
    363                 bbuf.clear();
     363                ((java.nio.Buffer)bbuf).clear();
    364364                bbufIsReadable = false;
    365365            } else {
    366                 int bbufEnd = bbufIsReadable ? bbuf.limit() : bbuf.position();
     366                int bbufEnd = bbufIsReadable
     367                  ? ((java.nio.Buffer)bbuf).limit()
     368                  : ((java.nio.Buffer)bbuf).position();
    367369                fcn.position(bbufpos + bbufEnd);
    368                 bbufpos += bbuf.position();
     370                bbufpos += ((java.nio.Buffer)bbuf).position();
    369371                if (bbufIsReadable) {
    370372                  bbuf.compact();
    371373                  bbufIsReadable = false;
    372                 } else //must discard the junk bytes after bbuf.position()
    373                   bbuf.clear();
     374                } else //must discard the junk bytes after ((java.nio.Buffer)bbuf).position()
     375                  ((java.nio.Buffer)bbuf).clear();
    374376            }
    375377
    376378            bufReady = (fcn.read(bbuf) != -1);
    377             bbuf.flip();
     379            ((java.nio.Buffer)bbuf).flip();
    378380            bbufIsReadable = true;
    379381        }
     
    434436            if (CoderResult.OVERFLOW == r || bbuf.remaining() == 0) {
    435437                flushBbuf(false);
    436                 bbuf.clear();
     438                ((java.nio.Buffer)bbuf).clear();
    437439                bbufIsReadable = false;
    438440            }
    439441            if (r.isUnmappable()) {
    440                 throw new RACFUnmappableCharacterException(cbuf.position(),
    441                                                            cbuf.charAt(cbuf.position()),
     442                throw new RACFUnmappableCharacterException(((java.nio.Buffer)cbuf).position(),
     443                                                           cbuf.charAt(((java.nio.Buffer)cbuf).position()),
    442444                                                           cset.name());
    443445            }
     
    445447                // We don't really expect Malformed, but not handling it
    446448                // will cause an infinite loop if we don't...
    447                 throw new RACFMalformedInputException(cbuf.position(),
    448                                                       cbuf.charAt(cbuf.position()),
     449                throw new RACFMalformedInputException(((java.nio.Buffer)cbuf).position(),
     450                                                      cbuf.charAt(((java.nio.Buffer)cbuf).position()),
    449451                                                      cset.name());
    450452            }
     
    452454            // before bbuf is filled.
    453455        }
    454         if (bbuf.position() > 0 && bbufIsDirty && flush) {
     456        if (((java.nio.Buffer)bbuf).position() > 0 && bbufIsDirty && flush) {
    455457            flushBbuf(false);
    456458        }
     
    460462        flushBbuf(true);
    461463        long bbufend = bbufpos // in case bbuf is readable, its contents is valid
    462             + (bbufIsReadable ? bbuf.limit() : bbuf.position()); // beyond position()
     464            + (bbufIsReadable
     465         ? ((java.nio.Buffer)bbuf).limit()
     466         : ((java.nio.Buffer)bbuf).position()); // beyond position()
    463467        if (newPosition >= bbufpos && newPosition < bbufend) {
    464468            // near seek. within existing data of bbuf.
    465469            if (!bbufIsReadable) { //rewinding. keep tail buffered.
    466               bbuf.limit(bbuf.position());
     470              ((java.nio.Buffer)bbuf).limit(((java.nio.Buffer)bbuf).position());
    467471              bbufIsReadable = true;
    468472            }
    469             bbuf.position((int)(newPosition - bbufpos));
     473            ((java.nio.Buffer)bbuf).position((int)(newPosition - bbufpos));
    470474        } else {
    471475            fcn.position(newPosition);
    472476            // far seek; discard the buffer (it's already cleared)
    473             bbuf.clear();
    474             bbuf.flip(); // "there is no useful data on this buffer yet."
     477            ((java.nio.Buffer)bbuf).clear();
     478            ((java.nio.Buffer)bbuf).flip(); // "there is no useful data on this buffer yet."
    475479            bbufIsReadable = true;
    476480            bbufpos = newPosition;
     
    479483
    480484    public final long position() throws IOException {
    481         return bbufpos + bbuf.position(); // the logical position within the file.
     485        return bbufpos + ((java.nio.Buffer)bbuf).position(); // the logical position within the file.
    482486    }
    483487
     
    499503        if (commitOnly) {
    500504            ByteBuffer dup = bbuf.duplicate();
    501             dup.flip();
     505            ((java.nio.Buffer)dup).flip();
    502506            fcn.write(dup);
    503507            //ideally, should restore fcn.position(). but don't for performance.
     
    508512       
    509513        if (bbufIsDirty) {
    510           bbuf.flip();
     514          ((java.nio.Buffer)bbuf).flip();
    511515          fcn.write(bbuf);
    512516        }
    513517
    514         bbufpos += bbuf.position();
    515         bbuf.clear();
    516         bbuf.flip(); // there's no useable data in this buffer
     518        bbufpos += ((java.nio.Buffer)bbuf).position();
     519        ((java.nio.Buffer)bbuf).clear();
     520        ((java.nio.Buffer)bbuf).flip(); // there's no useable data in this buffer
    517521        bbufIsDirty = false;
    518522        bbufIsReadable = true;
     
    557561            shortByteBuf = ByteBuffer.allocate((int)cenc.maxBytesPerChar());
    558562        }
    559         singleCharBuf.clear();
     563        ((java.nio.Buffer)singleCharBuf).clear();
    560564        singleCharBuf.append(c);
    561         singleCharBuf.flip();
    562         shortByteBuf.clear();
     565        ((java.nio.Buffer)singleCharBuf).flip();
     566        ((java.nio.Buffer)shortByteBuf).clear();
    563567        cenc.encode(singleCharBuf, shortByteBuf, false);
    564         int n = shortByteBuf.position();
     568        int n = ((java.nio.Buffer)shortByteBuf).position();
    565569        long pos = position() - n;
    566570        position(pos);
     
    577581            if (bbuf.remaining() == 0) {
    578582                flushBbuf(false);
    579                 bbuf.clear();
     583                ((java.nio.Buffer)bbuf).clear();
    580584                bbufIsReadable = false;
    581585            }
Note: See TracChangeset for help on using the changeset viewer.