本文整理汇总了Java中java.lang.IllegalAccessException类的典型用法代码示例。如果您正苦于以下问题:Java IllegalAccessException类的具体用法?Java IllegalAccessException怎么用?Java IllegalAccessException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IllegalAccessException类属于java.lang包,在下文中一共展示了IllegalAccessException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getByDescription
import java.lang.IllegalAccessException; //导入依赖的package包/类
public static BluetoothServiceId getByDescription(String description)
{
Field[] fields = BluetoothCommonServiceIds.class.getDeclaredFields();
for(Field f: fields)
{
try {
BluetoothServiceId id = (BluetoothServiceId)f.get(null);
if(id.mDescription.equals(description))
return id;
}
catch(IllegalAccessException e){
e.printStackTrace();
}
}
return null;
}
示例2: getDescription
import java.lang.IllegalAccessException; //导入依赖的package包/类
public static String getDescription(UUID serviceId)
{
Field[] fields = BluetoothCommonServiceIds.class.getDeclaredFields();
for(Field f: fields)
{
try {
BluetoothServiceId id = (BluetoothServiceId)f.get(null);
if(id.mUuid.equals(serviceId))
return id.mDescription;
}
catch (IllegalAccessException e){
e.printStackTrace();
}
}
return null;
}
示例3: getUuidByDescription
import java.lang.IllegalAccessException; //导入依赖的package包/类
public static UUID getUuidByDescription(String description)
{
Field[] fields = BluetoothCommonServiceIds.class.getDeclaredFields();
for(Field f: fields)
{
try {
BluetoothServiceId id = (BluetoothServiceId)f.get(null);
if(id.mDescription.equals(description))
return id.mUuid;
}
catch(IllegalAccessException e){
e.printStackTrace();
}
}
return null;
}
示例4: getFaviconId
import java.lang.IllegalAccessException; //导入依赖的package包/类
private static int getFaviconId(String name) {
try {
Class<?> drawablesClass = R.raw.class;
// Look for a favicon with the id R.raw.bookmarkdefaults_favicon_*.
Field faviconField = drawablesClass.getField(name.replace("_title_", "_favicon_"));
faviconField.setAccessible(true);
return faviconField.getInt(null);
} catch (IllegalAccessException | NoSuchFieldException e) {
// We'll end up here for any default bookmark that doesn't have a favicon in
// resources/raw/ (i.e., about:firefox). When this happens, the Favicons service will
// fall back to the default branding icon for about pages. Non-about pages should always
// specify an icon; otherwise, the placeholder globe favicon will be used.
Log.d(LOGTAG, "No raw favicon resource found for " + name);
}
Log.e(LOGTAG, "Failed to find favicon resource ID for " + name);
return FAVICON_ID_NOT_FOUND;
}
示例5: test
import java.lang.IllegalAccessException; //导入依赖的package包/类
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
IllegalAccessException object1 = new IllegalAccessException();
harness.check(object1 != null);
harness.check(object1.toString(), "java.lang.IllegalAccessException");
IllegalAccessException object2 = new IllegalAccessException("nothing happens");
harness.check(object2 != null);
harness.check(object2.toString(), "java.lang.IllegalAccessException: nothing happens");
IllegalAccessException object3 = new IllegalAccessException(null);
harness.check(object3 != null);
harness.check(object3.toString(), "java.lang.IllegalAccessException");
}
示例6: castFromStr
import java.lang.IllegalAccessException; //导入依赖的package包/类
/**
* instantiate an object from a given string
* @param c class of the object to instantiate
* @param s string to instantiate from
* @return instance of the specified class
* @throws NoSuchMethodException
* @throws IllegalAccessException
* @throws InvocationTargetException
*/
@SuppressWarnings("unchecked")
private static <T> T castFromStr(Class<T> c, String s)
throws NoSuchMethodException
, IllegalAccessException
, InvocationTargetException
{
if (String.class == c)
return (T) s;
Method m = c.getMethod("valueOf", String.class);
if (null == m)
{
throw new NoSuchMethodException
(
"Class " + c.getName()
+ " does not have the valueOf() method."
);
}
return (T) m.invoke(null, s);
}
示例7: onCreate
import java.lang.IllegalAccessException; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.main);
this.rnd = new Random();
this.handler = new Handler();
this.sp = new SoundPool(16, AudioManager.STREAM_MUSIC, 0);
this.sp.setOnLoadCompleteListener(this);
try {
this.buildSnd();
} catch (IllegalAccessException e) {
Log.e(HNY.TAG, "Oops: " + e.getMessage());
}
this.buildNumberPickers();
this.buildVibesButtons();
this.buildMainButton();
this.buildInfoButton();
this.setState(HNY.IDLE);
}
示例8: buildSnd
import java.lang.IllegalAccessException; //导入依赖的package包/类
private void buildSnd()
throws IllegalAccessException {
this.snd = new HashMap<String, Map<String, Integer>>();
this.sndLoading = 0;
for (Field f: R.raw.class.getFields()) {
final String name = f.getName();
final int split1 = name.indexOf('_') + 1;
final int split2 = name.indexOf('_', split1);
final String sndPx = name.substring(split1, split2);
final String sndLabel = name.substring(split2 + 1);
Map<String, Integer> sndList;
if (!this.snd.containsKey(sndPx)) {
sndList = new HashMap<String, Integer>();
this.snd.put(sndPx, sndList);
} else {
sndList = this.snd.get(sndPx);
}
this.sndLoading++;
sndList.put(sndLabel, this.sp.load(this, f.getInt(null), 1));
}
}
示例9: getTCL
import java.lang.IllegalAccessException; //导入依赖的package包/类
/**
* Get the Thread Context Loader which is a JDK 1.2 feature. If we
* are running under JDK 1.1 or anything else goes wrong the method
* returns <code>null<code>.
*
* */
private static ClassLoader getTCL() throws IllegalAccessException,
InvocationTargetException {
// Are we running on a JDK 1.2 or later system?
Method method = null;
try {
method = Thread.class.getMethod("getContextClassLoader", null);
} catch (NoSuchMethodException e) {
// We are running on JDK 1.1
return null;
}
return (ClassLoader) method.invoke(Thread.currentThread(), null);
}
示例10: mixinCreateTest3
import java.lang.IllegalAccessException; //导入依赖的package包/类
@Test
public void mixinCreateTest3( ) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
Query query = new Query( )
.setFirstRank( 0 )
.setNofRanks( 20 )
.addWeightingScheme(
new WeightingScheme( "bm25" )
.addParameter( "b", 0.77f )
.addParameter( "k1", 2 )
.addParameter( "avgdoclen", 11943 )
.addParameter( "metadata_doclen", "doclen" )
.addParameter( "match", "feat" ) )
.addSummarizer(
new SummarizerConfiguration( "docid", "attribute" )
.addParameter( "name", "docid" ) )
.addSummarizer(
new SummarizerConfiguration( "attr1", "attribute" )
.addParameter( "name", "attr1" ) )
.addSummarizer(
new SummarizerConfiguration( "doclen", "metadata" )
.addParameter( "name", "doclen" ) )
.defineFeature( "feat", "word", "aword0", 1.0f )
.defineFeature( "feat", new Term( "word", "aword1" ), 1.0f )
.defineFeature( "sel",
new Term( "word", "aword1" ), 1.0f )
.defineFeature( "sel",
new Expression( "contains", 0, 0 )
.addExpression(
new Expression( "contains", 0, 0 )
.addTerm( "word", "aword0" )
.addTerm( "word", "aword1" ) )
.addTerm( "word", "aword2" ), 1.0f )
.addSelect( "sel" )
// AND of OR-groups (CNF), first is a shortcut for a single and condition
.addMetadataRestriction(
new MetadataRestriction( MetadataCondition.COMPARE_GREATER_OR_EQUALS, "doclen", 2 )
)
.addMetadataRestriction(
new MetadataRestriction( )
.addCondition( MetadataCondition.COMPARE_GREATER, "doclen", 3 )
.addCondition( MetadataCondition.COMPARE_LESS_OR_EQUALS, "doclen", 100 )
);
// long for:
// QueryResponse response = new QueryResponse( query );
// in private static class in WebService:
Class<?> queryRequestClazz = Class.forName( "net.strus.service.impl.ws.WebService$QueryRequest" );
Constructor<?> constructor = queryRequestClazz.getDeclaredConstructor( Query.class );
constructor.setAccessible( true );
Object request = constructor.newInstance( query );
LOGGER.fine( request.toString( ) );
}
示例11: getByValue
import java.lang.IllegalAccessException; //导入依赖的package包/类
/**
* Given a TEnum class and integer value, this method will return
* the associated constant from the given TEnum class.
* This method MUST be modified should the name of the 'findByValue' method
* change.
*
* @param enumClass TEnum from which to return a matching constant.
* @param value Value for which to return the constant.
*
* @return The constant in 'enumClass' whose value is 'value' or null if
* something went wrong.
*/
public static TEnum getByValue(Class<? extends TEnum> enumClass, int value) {
try {
Method method = enumClass.getMethod("findByValue", int.class);
return (TEnum) method.invoke(null, value);
} catch (NoSuchMethodException nsme) {
return null;
} catch (IllegalAccessException iae) {
return null;
} catch (InvocationTargetException ite) {
return null;
}
}
示例12: test
import java.lang.IllegalAccessException; //导入依赖的package包/类
/**
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test(TestHarness harness)
{
// flag that is set when exception is caught
boolean caught = false;
try {
throw new IllegalAccessException("IllegalAccessException");
}
catch (IllegalAccessException e) {
// correct exception was caught
caught = true;
}
harness.check(caught);
}
示例13: sve_callMethod
import java.lang.IllegalAccessException; //导入依赖的package包/类
protected SveValue sve_callMethod(Object o, Method m, SveValue[] arg0) throws SveVariableNotFoundException, SveRuntimeException {
try {
if (m == null) return new SveValue(Type.NIL);
Object[] args = new Object[m.getParameterTypes().length];
if (arg0.length != args.length) return new SveValue(Type.NIL);
for (int i = 0; i < args.length; i++) {
Class<?> t = m.getParameterTypes()[i];
args[i] = sve_CreateJavaObject(arg0[i], t);
}
Class<?> r = m.getReturnType();
if (r.getName().equals(int.class.getName())) return new SveValue((int) m.invoke(o, args));
if (r.getName().equals(long.class.getName())) return new SveValue((long) m.invoke(o, args));
if (r.getName().equals(boolean.class.getName())) return new SveValue((boolean) m.invoke(o, args));
if (r.getName().equals(double.class.getName())) return new SveValue((double) m.invoke(o, args));
if (r.getName().equals(short.class.getName())) return new SveValue((short) m.invoke(o, args));
if (r.getName().equals(float.class.getName())) return new SveValue((float) m.invoke(o, args));
if (r.getName().equals(String.class.getName())) return new SveValue((String) m.invoke(o, args));
return sve_GetFromJavaObject(m.invoke(o, args));
} catch (IllegalAccessException | IllegalArgumentException
| InvocationTargetException e) {
e.printStackTrace();
throw new SveRuntimeException(0, ExceptionType.OTHER, e.toString());
}
}
示例14: sve_GetConstructor
import java.lang.IllegalAccessException; //导入依赖的package包/类
protected SveValue sve_GetConstructor(final Object o, final Constructor<?> m) {
SveValue method = new SveValue(Type.FUNCTION_JAVA);
method.method = new SveApiFunction() {
@Override
public SveValue call(SveValue[] arg0) throws SveRuntimeException {
try {
Object[] args = new Object[m.getParameterTypes().length];
if (arg0.length != args.length) return new SveValue(Type.NIL);
for (int i = 0; i < args.length; i++) {
Class<?> t = m.getParameterTypes()[i];
args[i] = sve_CreateJavaObject(arg0[i], t);
}
return sve_GetFromJavaObject(m.newInstance(args));
} catch (IllegalAccessException | IllegalArgumentException
| InvocationTargetException | InstantiationException e) {
e.printStackTrace();
throw new SveRuntimeException(0, ExceptionType.OTHER, e.toString());
}
}
};
method.table.setLocalVar("@fullname", new SveValue(m.toString()));
return method;
}
示例15: CannotInvokeException
import java.lang.IllegalAccessException; //导入依赖的package包/类
/**
* Constructs a CannotInvokeException with an IllegalAccessException.
*/
public CannotInvokeException(IllegalAccessException e) {
super("by " + e.toString());
err = e;
}