langtools/test/tools/javac/6330997/T6330997.java
changeset 22151 cb8daa93eeb1
parent 10180 b293c1f36ac4
child 24604 7f68545b5128
equal deleted inserted replaced
22150:af8945f58fc6 22151:cb8daa93eeb1
     1 /*
     1 /*
     2  * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 /**
    24 /**
    25  * @test
    25  * @test
    26  * @bug     6330997 7025789
    26  * @bug     6330997 7025789 8000961
    27  * @summary javac should accept class files with major version of the next release
    27  * @summary javac should accept class files with major version of the next release
    28  * @author  Wei Tao
    28  * @author  Wei Tao
    29  * @clean T1 T2
    29  * @clean T1 T2
    30  * @compile -target 8 T1.java
    30  * @compile -source 8 -target 8 T1.java
    31  * @compile -target 8 T2.java
    31  * @compile -source 8 -target 8 T2.java
    32  * @run main/othervm T6330997
    32  * @run main/othervm T6330997
    33  */
    33  */
    34 
    34 
    35 import java.nio.*;
    35 import java.nio.*;
    36 import java.io.*;
    36 import java.io.*;
    65         throw new RuntimeException("Failed: no error reported");
    65         throw new RuntimeException("Failed: no error reported");
    66     }
    66     }
    67 
    67 
    68     // Increase class file cfile's major version by delta
    68     // Increase class file cfile's major version by delta
    69     static void increaseMajor(String cfile, int delta) {
    69     static void increaseMajor(String cfile, int delta) {
    70         try {
    70         try (RandomAccessFile cls =
    71             RandomAccessFile cls = new RandomAccessFile(
    71              new RandomAccessFile(new File(System.getProperty("test.classes", "."), cfile), "rw");
    72                     new File(System.getProperty("test.classes", "."), cfile), "rw");
    72              FileChannel fc = cls.getChannel()) {
    73             FileChannel fc = cls.getChannel();
       
    74             ByteBuffer rbuf = ByteBuffer.allocate(2);
    73             ByteBuffer rbuf = ByteBuffer.allocate(2);
    75             fc.read(rbuf, 6);
    74             fc.read(rbuf, 6);
    76             ByteBuffer wbuf = ByteBuffer.allocate(2);
    75             ByteBuffer wbuf = ByteBuffer.allocate(2);
    77             wbuf.putShort(0, (short)(rbuf.getShort(0) + delta));
    76             wbuf.putShort(0, (short)(rbuf.getShort(0) + delta));
    78             fc.write(wbuf, 6);
    77             fc.write(wbuf, 6);
    79             fc.force(false);
    78             fc.force(false);
    80             cls.close();
    79         } catch (Exception e){
    81          } catch (Exception e){
       
    82             e.printStackTrace();
       
    83             throw new RuntimeException("Failed: unexpected exception");
    80             throw new RuntimeException("Failed: unexpected exception");
    84          }
    81          }
    85      }
    82      }
    86 }
    83 }