Class JarTypeSolver

java.lang.Object
com.github.javaparser.symbolsolver.resolution.typesolvers.JarTypeSolver
All Implemented Interfaces:
com.github.javaparser.resolution.TypeSolver

public class JarTypeSolver extends Object implements com.github.javaparser.resolution.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 pathToJarOrClassFileHierarchy)
    Create a JarTypeSolver from a File.
    JarTypeSolver(InputStream jarInputStream)
    Create a JarTypeSolver from a InputStream.
    JarTypeSolver(String pathToJarOrClassFileHierarchy)
    Create a JarTypeSolver from a path in a String format.
    JarTypeSolver(Path pathToJarOrClassFileHierarchy)
    Create a JarTypeSolver from a Path.
  • Method Summary

    Modifier and Type
    Method
    Description
    Deprecated.
    Use of this static method (previously following singleton pattern) is strongly discouraged and will be removed in a future version.
    Get the set of classes that can be resolved in the current type solver.
    com.github.javaparser.resolution.TypeSolver
     
    void
    setParent(com.github.javaparser.resolution.TypeSolver parent)
     
    com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration
     
    com.github.javaparser.resolution.model.SymbolReference<com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration>
     
    com.github.javaparser.resolution.model.SymbolReference<com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration>
    tryToSolveTypeInModule(String qualifiedModuleName, String simpleTypeName)
    https://docs.oracle.com/javase/specs/jvms/se25/html/jvms-4.html#jvms-4.7.25

    Methods inherited from class 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, solveTypeInModule
  • Constructor Details

    • JarTypeSolver

      public JarTypeSolver(Path pathToJarOrClassFileHierarchy) throws IOException
      Create a JarTypeSolver from a Path.
      Parameters:
      pathToJarOrClassFileHierarchy - The path where the jar or class file hierarchy is located.
      Throws:
      IOException - If an I/O exception occurs while reading the Jar or class file hierarchy.
    • JarTypeSolver

      public JarTypeSolver(File pathToJarOrClassFileHierarchy) throws IOException
      Create a JarTypeSolver from a File.
      Parameters:
      pathToJarOrClassFileHierarchy - The file pointing to the jar or class file hierarchy is located.
      Throws:
      IOException - If an I/O exception occurs while reading the Jar or class file hierarchy.
    • JarTypeSolver

      public JarTypeSolver(String pathToJarOrClassFileHierarchy) throws IOException
      Create a JarTypeSolver from a path in a String format.
      Parameters:
      pathToJarOrClassFileHierarchy - The path pointing to the jar or class file hierarchy.
      Throws:
      IOException - If an I/O exception occurs while reading the Jar or class file hierarchy.
    • JarTypeSolver

      public JarTypeSolver(InputStream jarInputStream) throws IOException
      Create a JarTypeSolver from a InputStream. 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 Details

    • 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 com.github.javaparser.resolution.TypeSolver getParent()
      Specified by:
      getParent in interface com.github.javaparser.resolution.TypeSolver
    • setParent

      public void setParent(com.github.javaparser.resolution.TypeSolver parent)
      Specified by:
      setParent in interface com.github.javaparser.resolution.TypeSolver
    • tryToSolveType

      public com.github.javaparser.resolution.model.SymbolReference<com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration> tryToSolveType(String name)
      Specified by:
      tryToSolveType in interface com.github.javaparser.resolution.TypeSolver
    • solveType

      public com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration solveType(String name) throws com.github.javaparser.resolution.UnsolvedSymbolException
      Specified by:
      solveType in interface com.github.javaparser.resolution.TypeSolver
      Throws:
      com.github.javaparser.resolution.UnsolvedSymbolException
    • tryToSolveTypeInModule

      public com.github.javaparser.resolution.model.SymbolReference<com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration> tryToSolveTypeInModule(String qualifiedModuleName, String simpleTypeName)
      https://docs.oracle.com/javase/specs/jvms/se25/html/jvms-4.html#jvms-4.7.25
      Specified by:
      tryToSolveTypeInModule in interface com.github.javaparser.resolution.TypeSolver
      Parameters:
      qualifiedModuleName -
      simpleTypeName -
      Returns: