Mercurial > hg > truffle
annotate graal/com.oracle.graal.debug/src/com/oracle/graal/debug/DebugConfigScope.java @ 19507:1cde96b96673
Fixed code format issues.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Thu, 19 Feb 2015 16:15:56 +0100 |
parents | 53b1edcf628f |
children |
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 */ |
53b1edcf628f
added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.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
|
24 |
53b1edcf628f
added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
25 import com.oracle.graal.debug.internal.*; |
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 } |