langtools/test/tools/javap/T8035104.java
author kshefov
Wed, 24 Sep 2014 14:19:25 +0400
changeset 26730 f71a6d13260c
parent 23797 756821688d0a
child 30730 d3ce7619db2c
permissions -rw-r--r--
8058653: [TEST_BUG] Test java/awt/Graphics2D/DrawString/DrawStringCrash.java fails with OutOfMemoryError Reviewed-by: serb, prr Contributed-by: srinivasan.raghavan@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23797
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
     1
/*
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
     4
 *
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
     7
 * published by the Free Software Foundation.
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
     8
 *
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    13
 * accompanied this code).
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    14
 *
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    18
 *
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    21
 * questions.
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    22
 */
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    23
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    24
/*
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    25
 * @test
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    26
 * @bug 8035104
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    27
 * @summary reorder class file attributes in javap listing
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    28
 */
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    29
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    30
import java.io.*;
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    31
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    32
public class T8035104 {
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    33
    public static void main(String[] args) throws Exception {
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    34
        new T8035104().run();
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    35
    }
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    36
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    37
    public void run() throws Exception {
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    38
        String[] lines = javap("-v", T8035104.class.getName()).split("[\r\n]+");
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    39
        int minor = -1;
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    40
        int SourceFile = -1;
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    41
        for (int i = 0; i < lines.length; i++) {
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    42
            String line = lines[i];
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    43
            if (line.matches(" *minor version: [0-9.]+"))
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    44
                minor = i;
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    45
            if (line.matches(" *SourceFile: .+"))
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    46
                SourceFile = i;
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    47
        }
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    48
        if (minor == -1)
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    49
            throw new Exception("minor version not found");
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    50
        if (SourceFile == -1)
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    51
            throw new Exception("SourceFile not found");
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    52
        if (SourceFile < minor)
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    53
            throw new Exception("unexpected order of output");
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    54
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    55
        System.out.println("output OK");
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    56
    }
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    57
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    58
    String javap(String... args) {
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    59
        StringWriter sw = new StringWriter();
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    60
        PrintWriter out = new PrintWriter(sw);
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    61
        int rc = com.sun.tools.javap.Main.run(args, out);
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    62
        out.close();
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    63
        System.out.println(sw.toString());
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    64
        System.out.println("javap exited, rc=" + rc);
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    65
        return sw.toString();
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    66
    }
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    67
}