jdk/test/java/beans/Introspector/Test7195106.java
author lana
Tue, 23 May 2017 21:11:42 +0000
changeset 45187 331a6542b5b8
parent 28965 9468d534ab8c
permissions -rw-r--r--
Added tag jdk-10+7 for changeset d554736d963e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13654
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
     1
/*
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
     2
 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
     4
 *
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
     8
 *
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    13
 * accompanied this code).
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    14
 *
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    18
 *
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    21
 * questions.
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    22
 */
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    23
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    24
/*
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    25
 * @test
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    26
 * @bug 7195106
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    27
 * @summary Tests that explicit BeanInfo is not collected
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    28
 * @author Sergey Malenkov
28965
9468d534ab8c 8072770: [TESTBUG] Some Introspector tests fail with a Java heap bigger than 4GB
simonis
parents: 13654
diff changeset
    29
 * @run main/othervm -Xmx128m Test7195106
13654
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    30
 */
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    31
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    32
import java.awt.Image;
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    33
import java.awt.image.BufferedImage;
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    34
import java.beans.BeanInfo;
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    35
import java.beans.Introspector;
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    36
import java.beans.SimpleBeanInfo;
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    37
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    38
public class Test7195106 {
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    39
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    40
    public static void main(String[] arg) throws Exception {
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    41
        BeanInfo info = Introspector.getBeanInfo(My.class);
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    42
        if (null == info.getIcon(BeanInfo.ICON_COLOR_16x16)) {
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    43
            throw new Error("Unexpected behavior");
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    44
        }
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    45
        try {
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    46
            int[] array = new int[1024];
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    47
            while (true) {
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    48
                array = new int[array.length << 1];
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    49
            }
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    50
        }
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    51
        catch (OutOfMemoryError error) {
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    52
            System.gc();
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    53
        }
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    54
        if (null == info.getIcon(BeanInfo.ICON_COLOR_16x16)) {
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    55
            throw new Error("Explicit BeanInfo is collected");
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    56
        }
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    57
    }
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    58
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    59
    public static class My {
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    60
    }
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    61
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    62
    public static class MyBeanInfo extends SimpleBeanInfo {
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    63
        @Override
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    64
        public Image getIcon(int type) {
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    65
            return new BufferedImage(16, 16, BufferedImage.TYPE_INT_RGB);
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    66
        }
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    67
    }
9a35ae08fd2b 7195106: REGRESSION : There is no way to get Icon inf, once Softreference is released
malenkov
parents:
diff changeset
    68
}