001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019package org.apache.commons.weaver.privilizer.example;
020
021import org.apache.commons.weaver.privilizer.Privileged;
022
023public abstract class StaticNoArgs {
024    private StaticNoArgs() {
025    }
026
027    @Privileged
028    static void throwAwayFoo() {
029        System.getProperty("foo");
030    }
031
032    @Privileged
033    static String getFoo() {
034        return System.getProperty("foo");
035    }
036
037    @Privileged
038    static Boolean getTrue() {
039        System.getProperty("foo");
040        return Boolean.TRUE;
041    }
042
043    @Privileged
044    static boolean getFalse() {
045        System.getProperty("foo");
046        return false;
047    }
048
049    public static class CheckedException1 extends Exception {
050        private static final long serialVersionUID = 1L;
051    }
052
053    public static class CheckedException2 extends Exception {
054        private static final long serialVersionUID = 1L;
055    }
056
057    @Privileged
058    static void throwingCheckedException1() throws CheckedException1 {
059        System.getProperty("foo");
060        throw new CheckedException1();
061    }
062
063    @Privileged
064    static Integer throwingCheckedException2() throws CheckedException1, CheckedException2 {
065        System.getProperty("foo");
066        throw new CheckedException2();
067    }
068}