当前位置: 首页>>代码示例>>Java>>正文


Java NoSuchMethodException类代码示例

本文整理汇总了Java中java.lang.NoSuchMethodException的典型用法代码示例。如果您正苦于以下问题:Java NoSuchMethodException类的具体用法?Java NoSuchMethodException怎么用?Java NoSuchMethodException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NoSuchMethodException类属于java.lang包,在下文中一共展示了NoSuchMethodException类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: verifyArrayFieldTypeAnnotations

import java.lang.NoSuchMethodException; //导入依赖的package包/类
private void verifyArrayFieldTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {

    Annotation anno;
    AnnotatedType at;

    at = c.getDeclaredField("typeAnnotatedArray").getAnnotatedType();
    anno = at.getAnnotations()[0];
    verifyTestAnn(arrayTA[0], anno, "array1");
    arrayTA[0] = anno;

    for (int i = 1; i <= 3; i++) {
        at = ((AnnotatedArrayType) at).getAnnotatedGenericComponentType();
        anno = at.getAnnotations()[0];
        verifyTestAnn(arrayTA[i], anno, "array" + (i + 1));
        arrayTA[i] = anno;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:RedefineAnnotations.java

示例2: main

import java.lang.NoSuchMethodException; //导入依赖的package包/类
public static void main(String argv[]) throws NoSuchFieldException, NoSuchMethodException {
    if (argv.length == 1 && argv[0].equals("buildagent")) {
        buildAgent();
        return;
    }

    if (inst == null) {
        throw new RuntimeException("Instrumentation object was null");
    }

    RedefineAnnotations test = new RedefineAnnotations();
    test.testTransformAndVerify();
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:14,代码来源:RedefineAnnotations.java

示例3: verifyInnerFieldTypeAnnotations

import java.lang.NoSuchMethodException; //导入依赖的package包/类
private void verifyInnerFieldTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {

    AnnotatedType at = c.getDeclaredField("typeAnnotatedInner").getAnnotatedType();
    Annotation anno = at.getAnnotations()[0];
    verifyTestAnn(innerTA, anno, "inner");
    innerTA = anno;
}
 
开发者ID:infobip,项目名称:infobip-open-jdk-8,代码行数:9,代码来源:RedefineAnnotations.java

示例4: verifyMethodTypeAnnotations

import java.lang.NoSuchMethodException; //导入依赖的package包/类
private void verifyMethodTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {
    Annotation anno;
    Executable typeAnnotatedMethod =
        c.getDeclaredMethod("typeAnnotatedMethod", TypeAnnotatedTestClass.class);

    anno = typeAnnotatedMethod.getAnnotatedReturnType().getAnnotations()[0];
    verifyTestAnn(returnTA, anno, "return");
    returnTA = anno;

    anno = typeAnnotatedMethod.getTypeParameters()[0].getAnnotations()[0];
    verifyTestAnn(methodTypeParameterTA, anno, "methodTypeParameter");
    methodTypeParameterTA = anno;

    anno = typeAnnotatedMethod.getAnnotatedParameterTypes()[0].getAnnotations()[0];
    verifyTestAnn(formalParameterTA, anno, "formalParameter");
    formalParameterTA = anno;

    anno = typeAnnotatedMethod.getAnnotatedExceptionTypes()[0].getAnnotations()[0];
    verifyTestAnn(throwsTA, anno, "throws");
    throwsTA = anno;
}
 
开发者ID:infobip,项目名称:infobip-open-jdk-8,代码行数:23,代码来源:RedefineAnnotations.java

示例5: castFromStr

import java.lang.NoSuchMethodException; //导入依赖的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);
}
 
开发者ID:LdTrigger,项目名称:soen343-ezim,代码行数:32,代码来源:EzimConf.java

示例6: testTransformAndVerify

import java.lang.NoSuchMethodException; //导入依赖的package包/类
private void testTransformAndVerify()
    throws NoSuchFieldException, NoSuchMethodException {

    Class<TypeAnnotatedTestClass> c = TypeAnnotatedTestClass.class;
    Class<?> myClass = c;

    /*
     * Verify that the expected annotations are where they should be before transform.
     */
    verifyClassTypeAnnotations(c);
    verifyFieldTypeAnnotations(c);
    verifyMethodTypeAnnotations(c);

    try {
        inst.addTransformer(new Transformer(), true);
        inst.retransformClasses(myClass);
    } catch (UnmodifiableClassException e) {
        throw new RuntimeException(e);
    }

    /*
     * Verify that the expected annotations are where they should be after transform.
     * Also verify that before and after are equal.
     */
    verifyClassTypeAnnotations(c);
    verifyFieldTypeAnnotations(c);
    verifyMethodTypeAnnotations(c);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:RedefineAnnotations.java

示例7: verifyFieldTypeAnnotations

import java.lang.NoSuchMethodException; //导入依赖的package包/类
private void verifyFieldTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {

    verifyBasicFieldTypeAnnotations(c);
    verifyInnerFieldTypeAnnotations(c);
    verifyArrayFieldTypeAnnotations(c);
    verifyMapFieldTypeAnnotations(c);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:RedefineAnnotations.java

示例8: verifyBasicFieldTypeAnnotations

import java.lang.NoSuchMethodException; //导入依赖的package包/类
private void verifyBasicFieldTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {

    Annotation anno = c.getDeclaredField("typeAnnotatedBoolean").getAnnotatedType().getAnnotations()[0];
    verifyTestAnn(fieldTA, anno, "field");
    fieldTA = anno;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:RedefineAnnotations.java

示例9: verifyMapFieldTypeAnnotations

import java.lang.NoSuchMethodException; //导入依赖的package包/类
private void verifyMapFieldTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {

    Annotation anno;
    AnnotatedType atBase;
    AnnotatedType atParameter;
    atBase = c.getDeclaredField("typeAnnotatedMap").getAnnotatedType();

    anno = atBase.getAnnotations()[0];
    verifyTestAnn(mapTA[0], anno, "map1");
    mapTA[0] = anno;

    atParameter =
        ((AnnotatedParameterizedType) atBase).
        getAnnotatedActualTypeArguments()[0];
    anno = ((AnnotatedWildcardType) atParameter).getAnnotations()[0];
    verifyTestAnn(mapTA[1], anno, "map2");
    mapTA[1] = anno;

    anno =
        ((AnnotatedWildcardType) atParameter).
        getAnnotatedUpperBounds()[0].getAnnotations()[0];
    verifyTestAnn(mapTA[2], anno, "map3");
    mapTA[2] = anno;

    atParameter =
        ((AnnotatedParameterizedType) atBase).
        getAnnotatedActualTypeArguments()[1];
    anno = ((AnnotatedParameterizedType) atParameter).getAnnotations()[0];
    verifyTestAnn(mapTA[3], anno, "map4");
    mapTA[3] = anno;

    anno =
        ((AnnotatedParameterizedType) atParameter).
        getAnnotatedActualTypeArguments()[0].getAnnotations()[0];
    verifyTestAnn(mapTA[4], anno, "map5");
    mapTA[4] = anno;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:39,代码来源:RedefineAnnotations.java

示例10: mixinCreateTest3

import java.lang.NoSuchMethodException; //导入依赖的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( ) );
}
 
开发者ID:Eurospider,项目名称:strusJavaApi,代码行数:54,代码来源:JacksonTest.java

示例11: getByValue

import java.lang.NoSuchMethodException; //导入依赖的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;
  }
}
 
开发者ID:adityayadav76,项目名称:internet_of_things_simulator,代码行数:25,代码来源:TEnumHelper.java

示例12: testApp

import java.lang.NoSuchMethodException; //导入依赖的package包/类
public void testApp()
   {
Method method = null;
try {
    method = Tracepoints.class.getDeclaredMethod("tracepoint0");
    assertNotNull("Method Tracepoints.tracepoint0 is null.", method);
} catch (NoSuchMethodException e) {
    assertTrue("Method tracepoint0 not found in class Tracepoints.", false);
}

PerfTracepoint tracepoint = method.getAnnotation(PerfTracepoint.class);
assertNotNull("PerfTracepoint instance is null.", tracepoint);
   }
 
开发者ID:twitter,项目名称:PerfTracepoint,代码行数:14,代码来源:PerfTracepointTest.java

示例13: getBaseClass

import java.lang.NoSuchMethodException; //导入依赖的package包/类
/**
 * Get the base class of classParam, for top level classes this returns null. For enums, inner and anonymous classes
 * it returns the enclosing class. The intent is to use this for enum support in Java 5+.
 * 
 * @param classParam
 *          class to get enclosing class of
 * @return Enclosing class
 * @throws NoSuchMethodException
 *           when run in pre Java 5.
 */
private static Class getBaseClass(Class classParam) throws NoSuchMethodException {
  String methodName = "getEnclosingClass";

  Method method = null;
  Class result = null;
  try {
    method = classParam.getClass().getMethod(methodName, (Class[]) null);
    result = (Class) method.invoke(classParam, (Object[]) null);
  } catch (Exception ex) {
    throw new NoSuchMethodException(ex.getMessage());
  }
  return result;
}
 
开发者ID:mybatis,项目名称:ibatis-2,代码行数:24,代码来源:UnknownTypeHandler.java


注:本文中的java.lang.NoSuchMethodException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。