logic: fix update of Java indexer to new version of Java dependencies

* reapplied previous reverts
* added cache for TypeSolvers in Java code
This commit is contained in:
malte_langkabel
2017-05-10 17:54:21 +02:00
parent f9a6c1ac09
commit 8a92453d60
39 changed files with 231 additions and 70 deletions
@@ -10,6 +10,18 @@ JavaEnvironment::~JavaEnvironment()
JavaEnvironmentFactory::getInstance()->unregisterEnvironment();
}
bool JavaEnvironment::callStaticVoidMethod(std::string className, std::string methodName)
{
jclass javaClass = getJavaClass(className);
jmethodID javaMethodId = getJavaStaticMethod(javaClass, methodName, "()V");
if(javaMethodId != nullptr)
{
m_env->CallStaticVoidMethod(javaClass, javaMethodId);
return true;
}
return false;
}
bool JavaEnvironment::callStaticVoidMethod(std::string className, std::string methodName, int arg1, std::string arg2, std::string arg3, std::string arg4, int arg5)
{
jclass javaClass = getJavaClass(className);
@@ -32,6 +32,7 @@ public:
};
~JavaEnvironment();
bool callStaticVoidMethod(std::string className, std::string methodName);
bool callStaticVoidMethod(std::string className, std::string methodName, int arg1, std::string arg2, std::string arg3, std::string arg4, int arg5);
bool callStaticMethod(std::string className, std::string methodName, std::string& ret, std::string arg1);
@@ -28,7 +28,6 @@ void JavaEnvironmentFactory::createInstance(std::string classPath, std::string&
}
std::function<jint (JavaVM**, void**, void*)> createInstanceFunction;
const FilePath javaPath(ApplicationSettings::getInstance()->getJavaPath());
createInstanceFunction = utility::loadFunctionFromLibrary<jint, JavaVM**, void**, void*>(
javaPath,
+17 -1
View File
@@ -26,7 +26,7 @@ std::string JavaParser::prepareJavaEnvironment()
const std::string separator = ":";
#endif
JavaEnvironmentFactory::createInstance(
ResourcePaths::getJavaPath().str() + "guava-18.0.jar" + separator +
ResourcePaths::getJavaPath().str() + "guava-21.0.jar" + separator +
ResourcePaths::getJavaPath().str() + "java-indexer.jar" + separator +
ResourcePaths::getJavaPath().str() + "javaparser-core.jar" + separator +
ResourcePaths::getJavaPath().str() + "javaslang-2.0.3.jar" + separator +
@@ -41,6 +41,22 @@ std::string JavaParser::prepareJavaEnvironment()
return errorString;
}
void JavaParser::clearCaches()
{
std::shared_ptr<JavaEnvironmentFactory> factory = JavaEnvironmentFactory::getInstance();
if (factory)
{
std::shared_ptr<JavaEnvironment> environment = factory->createEnvironment();
if (environment)
{
environment->callStaticVoidMethod(
"com/sourcetrail/JavaIndexer",
"clearCaches"
);
}
}
}
JavaParser::JavaParser(std::shared_ptr<ParserClient> client, std::shared_ptr<FileRegister> fileRegister)
: Parser(client)
, m_id(s_nextParserId++)
@@ -33,6 +33,7 @@ class JavaParser: public Parser
public:
// returns: error message
static std::string prepareJavaEnvironment();
static void clearCaches();
JavaParser(std::shared_ptr<ParserClient> client, std::shared_ptr<FileRegister> fileRegister);
~JavaParser();