Class JarTypeSolver
- java.lang.Object
-
- com.github.javaparser.symbolsolver.resolution.typesolvers.JarTypeSolver
-
- All Implemented Interfaces:
TypeSolver
public class JarTypeSolver extends Object implements TypeSolver
Will let the symbol solver look inside a jar file while solving types.- Author:
- Federico Tomassetti
-
-
Field Summary
-
Fields inherited from interface com.github.javaparser.resolution.TypeSolver
JAVA_LANG_OBJECT, JAVA_LANG_RECORD
-
-
Constructor Summary
Constructors Constructor Description JarTypeSolver(File pathToJar)Create aJarTypeSolverfrom aFile.JarTypeSolver(InputStream jarInputStream)Create aJarTypeSolverfrom aInputStream.JarTypeSolver(String pathToJar)Create aJarTypeSolverfrom a path in aStringformat.JarTypeSolver(Path pathToJar)Create aJarTypeSolverfrom aPath.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static JarTypeSolvergetJarTypeSolver(String pathToJar)Deprecated.Use of this static method (previously following singleton pattern) is strongly discouraged and will be removed in a future version.Set<String>getKnownClasses()Get the set of classes that can be resolved in the current type solver.TypeSolvergetParent()voidsetParent(TypeSolver parent)ResolvedReferenceTypeDeclarationsolveType(String name)SymbolReference<ResolvedReferenceTypeDeclaration>tryToSolveType(String name)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.github.javaparser.resolution.TypeSolver
getRoot, getSolvedJavaLangObject, getSolvedJavaLangRecord, hasType
-
-
-
-
Constructor Detail
-
JarTypeSolver
public JarTypeSolver(Path pathToJar) throws IOException
Create aJarTypeSolverfrom aPath.- Parameters:
pathToJar- The path where the jar is located.- Throws:
IOException- If an I/O exception occurs while reading the Jar.
-
JarTypeSolver
public JarTypeSolver(File pathToJar) throws IOException
Create aJarTypeSolverfrom aFile.- Parameters:
pathToJar- The file pointing to the jar is located.- Throws:
IOException- If an I/O exception occurs while reading the Jar.
-
JarTypeSolver
public JarTypeSolver(String pathToJar) throws IOException
Create aJarTypeSolverfrom a path in aStringformat.- Parameters:
pathToJar- The path pointing to the jar.- Throws:
IOException- If an I/O exception occurs while reading the Jar.
-
JarTypeSolver
public JarTypeSolver(InputStream jarInputStream) throws IOException
Create aJarTypeSolverfrom aInputStream. The content will be dumped into a temporary file to be used in the type solver.- Parameters:
jarInputStream- The input stream to be used.- Throws:
IOException- If an I/O exception occurs while creating the temporary file.
-
-
Method Detail
-
getJarTypeSolver
@Deprecated public static JarTypeSolver getJarTypeSolver(String pathToJar) throws IOException
Deprecated.Use of this static method (previously following singleton pattern) is strongly discouraged and will be removed in a future version. For now, it has been modified to return a new instance to prevent the IllegalStateException being thrown (as reported in #2547), allowing it to be called multiple times.- Throws:
IOException
-
getKnownClasses
public Set<String> getKnownClasses()
Get the set of classes that can be resolved in the current type solver.- Returns:
- The set of known classes.
-
getParent
public TypeSolver getParent()
- Specified by:
getParentin interfaceTypeSolver
-
setParent
public void setParent(TypeSolver parent)
- Specified by:
setParentin interfaceTypeSolver
-
tryToSolveType
public SymbolReference<ResolvedReferenceTypeDeclaration> tryToSolveType(String name)
- Specified by:
tryToSolveTypein interfaceTypeSolver
-
solveType
public ResolvedReferenceTypeDeclaration solveType(String name) throws UnsolvedSymbolException
- Specified by:
solveTypein interfaceTypeSolver- Throws:
UnsolvedSymbolException
-
-