jdk/test/java/beans/Introspector/Test7195106.java
changeset 13654 9a35ae08fd2b
child 28965 9468d534ab8c
equal deleted inserted replaced
13653:012c6f8f0279 13654:9a35ae08fd2b
       
     1 /*
       
     2  * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     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
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  */
       
    23 
       
    24 /*
       
    25  * @test
       
    26  * @bug 7195106
       
    27  * @summary Tests that explicit BeanInfo is not collected
       
    28  * @author Sergey Malenkov
       
    29  */
       
    30 
       
    31 import java.awt.Image;
       
    32 import java.awt.image.BufferedImage;
       
    33 import java.beans.BeanInfo;
       
    34 import java.beans.Introspector;
       
    35 import java.beans.SimpleBeanInfo;
       
    36 
       
    37 public class Test7195106 {
       
    38 
       
    39     public static void main(String[] arg) throws Exception {
       
    40         BeanInfo info = Introspector.getBeanInfo(My.class);
       
    41         if (null == info.getIcon(BeanInfo.ICON_COLOR_16x16)) {
       
    42             throw new Error("Unexpected behavior");
       
    43         }
       
    44         try {
       
    45             int[] array = new int[1024];
       
    46             while (true) {
       
    47                 array = new int[array.length << 1];
       
    48             }
       
    49         }
       
    50         catch (OutOfMemoryError error) {
       
    51             System.gc();
       
    52         }
       
    53         if (null == info.getIcon(BeanInfo.ICON_COLOR_16x16)) {
       
    54             throw new Error("Explicit BeanInfo is collected");
       
    55         }
       
    56     }
       
    57 
       
    58     public static class My {
       
    59     }
       
    60 
       
    61     public static class MyBeanInfo extends SimpleBeanInfo {
       
    62         @Override
       
    63         public Image getIcon(int type) {
       
    64             return new BufferedImage(16, 16, BufferedImage.TYPE_INT_RGB);
       
    65         }
       
    66     }
       
    67 }