예제 #1
0
std::ostream& Configuration::outputHelp(std::ostream& out) const {
	out << "---------------------------------------------------------------------------------------"<< std::endl;
	outputVersion(out) 
		<< "---------------------------------------------------------------------------------------"<< std::endl
		<< "Usage: " ;
		if (binaryName()) out << *binaryName();
		else out << "<binary>";
		out << " [<OPTIONS>] [<CONSTANTS>] <INPUT_FILES>" 											<< std::endl
		<< "---------------------------------------------------------------------------------------"<< std::endl
		<< "OPTIONS:"																				<< std::endl;
	outputOptions(out);
	out 																							<< std::endl
		<< "CONSTANTS:"																				<< std::endl
		<< "     <identifier>=<value>"																<< std::endl
		<< "          - Defines <identifier> to be a macro which expands to <value>"				<< std::endl;
	return out;
}
예제 #2
0
jclass JClassImpl::getClass() const throw ( JNIException ) {
    if ( mClass ) {
        return mClass;
    }

    JNIEnv* env = helper::attach();

	jobject classLoader = jace::helper::getClassLoader();
	jclass localClass;

    if ( classLoader != 0 ) {
        std::string binaryName( getName() );
		
		// Replace '/' by '.' in the name
        std::replace(binaryName.begin(), binaryName.end(), '/', '.');

		jclass classLoaderClass = env->GetObjectClass( classLoader );
		jmethodID loadClass = env->GetMethodID( classLoaderClass, "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;" );
		if ( loadClass == 0 ) {
			string msg = "JClass::getClass - Unable to find the method JNIHelper::getClassLoader().loadClass()";
			try
			{
				helper::catchAndThrow();
			}
			catch (JNIException& e)
			{
				msg.append("\ncaused by:\n");
				msg.append(e.what());
			}
			throw JNIException( msg );
		}
		jstring javaString = env->NewStringUTF( binaryName.c_str() );
		localClass = static_cast<jclass>( env->CallObjectMethod( classLoader, loadClass, javaString ) );
		env->DeleteLocalRef( javaString );
    } else {
        localClass = env->FindClass( getName().c_str() );
    }

    if ( ! localClass ) {
        string msg = "JClass::getClass - Unable to find the class <" + getName() + ">";
		try
		{
			helper::catchAndThrow();
		}
		catch (JNIException& e)
		{
			msg.append("\ncaused by:\n");
			msg.append(e.what());
		}
        throw JNIException( msg );
    }

    mClass = static_cast<jclass>( helper::newGlobalRef( env, localClass ) );
    helper::deleteLocalRef( env, localClass );
    return mClass;
}
예제 #3
0
std::ostream& Configuration::outputVersion(std::ostream& out) const {
	if (binaryName()) out << *binaryName() << " ";
	if (version()) out << "version " << *version() << std::endl;
	return out;
}