jdk/test/java/lang/ref/FinalizeOverride.java
author rriggs
Tue, 12 Jan 2016 17:54:09 -0500 (2016-01-12)
changeset 34950 7593604a704d
parent 21628 50fd58446d64
child 36415 a172186ba1ca
permissions -rw-r--r--
8146671: [TEST BUG] java/lang/ref/CleanerTest.java required more memory for -UseCompressedOops runs Reviewed-by: joehw
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21628
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
     1
/*
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
     4
 *
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
     7
 * published by the Free Software Foundation.
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
     8
 *
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    13
 * accompanied this code).
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    14
 *
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    18
 *
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    21
 * questions.
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    22
 */
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    23
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    24
import java.io.ByteArrayOutputStream;
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    25
import java.io.IOException;
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    26
import java.nio.file.Files;
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    27
import java.nio.file.Path;
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    28
import java.nio.file.Paths;
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    29
import java.util.concurrent.atomic.AtomicInteger;
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    30
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    31
/* @test
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    32
 * @bug 8027351
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    33
 * @summary Basic test of the finalize method
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    34
 */
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    35
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    36
public class FinalizeOverride {
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    37
    // finalizedCount is incremented when the finalize method is invoked
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    38
    private static AtomicInteger finalizedCount = new AtomicInteger();
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    39
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    40
    // finalizedSum and privateFinalizedInvoke are used to verify
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    41
    // the right overrided finalize method is invoked
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    42
    private static AtomicInteger finalizedSum = new AtomicInteger();
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    43
    private static volatile boolean privateFinalizeInvoked = false;
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    44
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    45
    public static void main(String[] argvs) throws IOException {
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    46
        patchPrivateFinalize();
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    47
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    48
        test(new Base(10), 10);
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    49
        test(new Subclass(20), 0);
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    50
        test(new SubSubclass(30), 30);
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    51
        test(new PublicFinalize(40), 40*100+40);
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    52
        test(new PrivateFinalize(50), 50);
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    53
        test(new NoOverride(60), 60);
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    54
    }
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    55
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    56
    static void test(Object o, int expected) {
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    57
        int count = finalizedCount.get();
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    58
        int sum = finalizedSum.get();
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    59
        privateFinalizeInvoked = false;
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    60
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    61
        // force GC and finalization
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    62
        o = null;
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    63
        while (finalizedCount.get() != (count+1)) {
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    64
            System.gc();
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    65
            System.runFinalization();
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    66
        }
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    67
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    68
        if (privateFinalizeInvoked) {
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    69
            throw new RuntimeException("private finalize method invoked");
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    70
        }
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    71
        if (finalizedCount.get() != (count+1)) {
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    72
            throw new RuntimeException("Unexpected count=" + finalizedCount +
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    73
                " expected=" + (count+1));
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    74
        }
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    75
        if (finalizedSum.get() != (sum+expected)) {
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    76
            throw new RuntimeException("Unexpected sum=" + finalizedSum +
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    77
                " prev=" + sum + " value=" + expected);
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    78
        }
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    79
    }
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    80
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    81
    static void patchPrivateFinalize() throws IOException {
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    82
        // patch the private f_nal_ze method name to "finalize"
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    83
        String testClasses = System.getProperty("test.classes", ".");
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    84
        Path p = Paths.get(testClasses, "FinalizeOverride$PrivateFinalize.class");
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    85
        byte[] bytes = Files.readAllBytes(p);
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    86
        int len = "f_nal_ze".length();
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    87
        for (int i=0; i < bytes.length-len; i++) {
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    88
            if (bytes[i] == 'f' &&
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    89
                bytes[i+1] == '_' &&
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    90
                bytes[i+2] == 'n' &&
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    91
                bytes[i+3] == 'a' &&
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    92
                bytes[i+4] == 'l' &&
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    93
                bytes[i+5] == '_' &&
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    94
                bytes[i+6] == 'z' &&
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    95
                bytes[i+7] == 'e')
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    96
            {
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    97
                // s%_%i%
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    98
                bytes[i+1] = 'i';
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
    99
                bytes[i+5] = 'i';
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   100
                break;
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   101
            }
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   102
        }
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   103
        Files.write(p, bytes);
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   104
    }
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   105
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   106
    static class Base {
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   107
        protected int value;
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   108
        Base(int v) {
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   109
            this.value = v;
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   110
        }
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   111
        int called() {
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   112
            finalizedSum.addAndGet(value);
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   113
            return value;
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   114
        }
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   115
        protected void finalize() {
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   116
            System.out.println("Base.finalize() sum += " + called());
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   117
            finalizedCount.incrementAndGet();
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   118
        }
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   119
    }
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   120
    static class PublicFinalize extends Base {
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   121
        PublicFinalize(int v) {
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   122
            super(v);
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   123
        }
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   124
        public void finalize() {
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   125
            finalizedSum.addAndGet(value * 100);
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   126
            System.out.println("PublicFinalize.finalize() sum += " + called() +
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   127
                "+"+value+"*100");
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   128
            finalizedCount.incrementAndGet();
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   129
        }
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   130
    }
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   131
    static class Subclass extends Base {
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   132
        Subclass(int v) {
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   133
            super(v);
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   134
        }
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   135
        protected void finalize() {
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   136
            // no value added to sum
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   137
            System.out.println("Subclass.finalize() sum += 0");
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   138
            finalizedCount.incrementAndGet();
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   139
        }
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   140
    }
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   141
    static class SubSubclass extends Subclass {
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   142
        SubSubclass(int v) {
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   143
            super(v);
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   144
        }
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   145
        protected final void finalize() {
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   146
            finalizedSum.addAndGet(value);
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   147
            System.out.println("SubSubclass.finalize() sum +=" +value);
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   148
            finalizedCount.incrementAndGet();
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   149
        }
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   150
    }
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   151
    static class PrivateFinalize extends Base {
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   152
        PrivateFinalize(int v) {
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   153
            super(v);
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   154
        }
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   155
        private void f_nal_ze() {
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   156
            // finalization catches any exception
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   157
            System.out.println("Error: private finalize invoked!!");
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   158
            privateFinalizeInvoked = true;
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   159
            finalizedCount.incrementAndGet();
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   160
        }
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   161
    }
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   162
    static class NoOverride extends PrivateFinalize {
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   163
        NoOverride(int v) {
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   164
            super(v);
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   165
        }
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   166
    }
50fd58446d64 8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
diff changeset
   167
}