annotate graal/com.oracle.jvmci.debug/src/com/oracle/jvmci/debug/DebugConfigScope.java @ 21694:ed731ad12a10

Make stamp of checkcast more precise.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Wed, 03 Jun 2015 13:08:13 +0200
parents b1530a6cce8c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13158
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1 /*
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4 *
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
8 *
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
13 * accompanied this code).
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
14 *
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
18 *
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
21 * questions.
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
22 */
21554
b1530a6cce8c renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 19507
diff changeset
23 package com.oracle.jvmci.debug;
13158
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
24
21554
b1530a6cce8c renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 19507
diff changeset
25 import com.oracle.jvmci.debug.internal.*;
13158
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
26
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
27 /**
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
28 * A utility for scoping a change to the current debug
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
29 * {@linkplain DebugScope#setConfig(DebugConfig) configuration}. For example:
19507
1cde96b96673 Fixed code format issues.
Roland Schatz <roland.schatz@oracle.com>
parents: 13158
diff changeset
30 *
13158
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
31 * <pre>
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
32 * DebugConfig config = ...;
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
33 * try (DebugConfigScope s = new DebugConfigScope(config)) {
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
34 * // ...
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
35 * }
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
36 * </pre>
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
37 */
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
38 public class DebugConfigScope implements AutoCloseable {
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
39
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
40 private final DebugConfig current;
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
41
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
42 /**
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
43 * Sets the current debug {@linkplain DebugScope#setConfig(DebugConfig) configuration} to a
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
44 * given value and creates an object that when {@linkplain #close() closed} resets the
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
45 * configuration to the {@linkplain DebugScope#getConfig() current} configuration.
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
46 */
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
47 public DebugConfigScope(DebugConfig config) {
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
48 this.current = DebugScope.getConfig();
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
49 DebugScope.getInstance().setConfig(config);
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
50 }
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
51
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
52 public void close() {
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
53 DebugScope.getInstance().setConfig(current);
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
54 }
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
55 }