test/hotspot/jtreg/serviceability/sa/LingeredAppWithInterface.java
author jgeorge
Fri, 01 Dec 2017 18:19:39 +0530
changeset 48181 61a14b5cb1c6
parent 47216 71c04702a3d5
permissions -rw-r--r--
8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol Summary: Create tests for the clhsdb commands: vmstructsdump, field, symboltable and symbol Reviewed-by: sspitsyn, sballal
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
43979
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
     1
/*
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
     4
 *
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
     7
 * published by the Free Software Foundation.
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
     8
 *
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    13
 * accompanied this code).
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    14
 *
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    18
 *
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    21
 * questions.
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    22
 */
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    23
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    24
import jdk.test.lib.apps.LingeredApp;
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    25
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    26
interface Language {
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    27
    static final long nbrOfWords = 99999;
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    28
    public abstract long getNbrOfWords();
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    29
}
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    30
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    31
class ParselTongue implements Language {
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    32
    public long getNbrOfWords() {
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    33
        return nbrOfWords * 4;
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    34
    }
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    35
}
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    36
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    37
public class LingeredAppWithInterface extends LingeredApp {
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    38
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    39
    public static void main(String args[]) {
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    40
        ParselTongue lang = new ParselTongue();
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    41
        Language muggleSpeak = new Language() {
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    42
            public long getNbrOfWords() {
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    43
                return nbrOfWords * 8;
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    44
            }
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    45
        };
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    46
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    47
        // Not tested at this point. The test needs to be enhanced
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    48
        // later to test for the sizes of the Lambda MetaFactory
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    49
        // generated anonymous classes too. (After JDK-8160228 gets
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    50
        // fixed.)
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    51
        Runnable r2 = () -> System.out.println("Hello world!");
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    52
        r2.run();
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    53
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    54
        System.out.println(lang.getNbrOfWords() + muggleSpeak.getNbrOfWords());
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    55
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    56
        LingeredApp.main(args);
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    57
    }
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents:
diff changeset
    58
}