<commit_before>/*
 * Bytecode Analysis Framework
 * Copyright (C) 2003-2005 University of Maryland
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package edu.umd.cs.findbugs.ba.ch;

import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

import org.apache.bcel.classfile.Field;
import org.apache.bcel.classfile.JavaClass;
import org.apache.bcel.classfile.Method;

import edu.umd.cs.findbugs.SystemProperties;
import edu.umd.cs.findbugs.ba.AnalysisContext;
import edu.umd.cs.findbugs.ba.XClass;
import edu.umd.cs.findbugs.ba.XFactory;
import edu.umd.cs.findbugs.classfile.CheckedAnalysisException;
import edu.umd.cs.findbugs.classfile.ClassDescriptor;
import edu.umd.cs.findbugs.classfile.DescriptorFactory;
import edu.umd.cs.findbugs.classfile.Global;

/**
 * Support for class hierarchy queries.
 * 
 * @author <NAME>
 * @author <NAME>
 */
@Deprecated // use Subtypes2 instead
public class Subtypes {
	private static final boolean DEBUG_HIERARCHY = false || SystemProperties.getBoolean("findbugs.debug.hierarchy");
	
	/**
	 * This boolean property may be set to completely disable the use of
	 * this (deprecated) class.  Assuming that tests verify that no breakage
	 * results, we'll go ahead and completely eliminate this class. 
	 */
	public static final boolean DO_NOT_USE = SystemProperties.getBoolean("subtypes.donotuse");
	
	public Subtypes() {
		if (DO_NOT_USE) {
			throw new IllegalStateException("Subtypes is supposed to be disabled!");
		}
	}

	/**
	 * Get immediate subtypes of given class or interface.
	 * 
	 * @param c a class or interface
	 * @return set of immediate subtypes
	 */

	public Set<JavaClass> getImmediateSubtypes(JavaClass c) {
		ClassDescriptor classDescriptor = DescriptorFactory.createClassDescriptor(c);
		try {
	        return getJavaClasses(subtypes2().getSubtypes(classDescriptor));
        } catch (ClassNotFoundException e) {
	        AnalysisContext.reportMissingClass(e);
	        return Collections.<JavaClass>emptySet();
        } catch (CheckedAnalysisException e) {
        	 AnalysisContext.logError("Error checking subtypes of " + c.getClassName(), e);<commit_msg>Changed so that the DO_NOT_USE property is set to true by default.<commit_after>/*
 * Bytecode Analysis Framework
 * Copyright (C) 2003-2005 University of Maryland
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package edu.umd.cs.findbugs.ba.ch;

import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

import org.apache.bcel.classfile.Field;
import org.apache.bcel.classfile.JavaClass;
import org.apache.bcel.classfile.Method;

import edu.umd.cs.findbugs.SystemProperties;
import edu.umd.cs.findbugs.ba.AnalysisContext;
import edu.umd.cs.findbugs.ba.XClass;
import edu.umd.cs.findbugs.ba.XFactory;
import edu.umd.cs.findbugs.classfile.CheckedAnalysisException;
import edu.umd.cs.findbugs.classfile.ClassDescriptor;
import edu.umd.cs.findbugs.classfile.DescriptorFactory;
import edu.umd.cs.findbugs.classfile.Global;

/**
 * Support for class hierarchy queries.
 * 
 * @author <NAME>
 * @author <NAME>
 */
@Deprecated // use Subtypes2 instead
public class Subtypes {
	private static final boolean DEBUG_HIERARCHY = false || SystemProperties.getBoolean("findbugs.debug.hierarchy");
	
	/**
	 * This boolean property may be set to completely disable the use of
	 * this (deprecated) class.  Assuming that tests verify that no breakage
	 * results, we'll go ahead and completely eliminate this class. 
	 */
	public static final boolean DO_NOT_USE = SystemProperties.getBoolean("subtypes.donotuse", true);
	
	public Subtypes() {
		if (DO_NOT_USE) {
			throw new IllegalStateException("Subtypes is supposed to be disabled!");
		}
	}

	/**
	 * Get immediate subtypes of given class or interface.
	 * 
	 * @param c a class or interface
	 * @return set of immediate subtypes
	 */

	public Set<JavaClass> getImmediateSubtypes(JavaClass c) {
		ClassDescriptor classDescriptor = DescriptorFactory.createClassDescriptor(c);
		try {
	        return getJavaClasses(subtypes2().getSubtypes(classDescriptor));
        } catch (ClassNotFoundException e) {
	        AnalysisContext.reportMissingClass(e);
	        return Collections.<JavaClass>emptySet();
        } catch (CheckedAnalysisException e) {
        	 AnalysisContext.logError("Error checking subtypes of " + c.getClassName(), e);
{'fraction_non_alphanumeric': 0.08809811711867335, 'fraction_numerical': 0.00898255311798238, 'mean_word_length': 4.160427807486631, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4329873', 'n_tokens_mistral': 1732, 'n_tokens_neox': 1603, 'n_words': 559}