test/langtools/tools/javap/T8035104.java
author vlivanov
Tue, 26 Nov 2019 16:09:21 +0300
changeset 59276 94a84abb873b
parent 47216 71c04702a3d5
permissions -rw-r--r--
8234403: C2: Enable CallSite.target updates in constructors Reviewed-by: psandoz, kvn
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
/*
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 30846
diff changeset
     2
 * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
23797
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
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 30846
diff changeset
    28
 * @modules jdk.jdeps/com.sun.tools.javap
23797
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
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    31
import java.io.*;
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    32
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    33
public class T8035104 {
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    34
    public static void main(String[] args) throws Exception {
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    35
        new T8035104().run();
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
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    38
    public void run() throws Exception {
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    39
        String[] lines = javap("-v", T8035104.class.getName()).split("[\r\n]+");
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    40
        int minor = -1;
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    41
        int SourceFile = -1;
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    42
        for (int i = 0; i < lines.length; i++) {
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    43
            String line = lines[i];
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    44
            if (line.matches(" *minor version: [0-9.]+"))
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    45
                minor = i;
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    46
            if (line.matches(" *SourceFile: .+"))
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    47
                SourceFile = i;
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    48
        }
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    49
        if (minor == -1)
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    50
            throw new Exception("minor version not found");
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    51
        if (SourceFile == -1)
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    52
            throw new Exception("SourceFile not found");
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    53
        if (SourceFile < minor)
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    54
            throw new Exception("unexpected order of output");
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    55
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    56
        System.out.println("output OK");
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
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    59
    String javap(String... args) {
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    60
        StringWriter sw = new StringWriter();
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    61
        PrintWriter out = new PrintWriter(sw);
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    62
        int rc = com.sun.tools.javap.Main.run(args, out);
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    63
        out.close();
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    64
        System.out.println(sw.toString());
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    65
        System.out.println("javap exited, rc=" + rc);
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    66
        return sw.toString();
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    67
    }
756821688d0a 8035104: reorder class file attributes in javap listing
jjg
parents:
diff changeset
    68
}