Package jep
Interface ClassEnquirer
-
- All Known Implementing Classes:
ClassList
,NamingConventionClassEnquirer
public interface ClassEnquirer
Interface to enquire if a name is available to be imported from Java. Used by Jep's importer hook (see PEP 302) to determine if an attempt to import a module/package or class should be directed to the Python importer or the JavaClassLoader
.- Since:
- 3.3
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String[]
RESTRICTED_PKG_NAMES
Certain Java libraries (e.g.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.String[]
getClassNames(java.lang.String pkgName)
Given a Java package name, gets the fully-qualified classnames available for import in the package.java.lang.String[]
getSubPackages(java.lang.String pkgName)
Given a Java package name, gets the sub-packages available.boolean
isJavaPackage(java.lang.String name)
Checks if the name is likely available in Java as a package.
-
-
-
Field Detail
-
RESTRICTED_PKG_NAMES
static final java.lang.String[] RESTRICTED_PKG_NAMES
Certain Java libraries (e.g. io.netty) may meet Java package naming standards but will conflict with modules that Python provides (e.g. import io). In general these package names should not be considered as Java packages unless a ClassEnquirer explicitly chooses to include them.
-
-
Method Detail
-
isJavaPackage
boolean isJavaPackage(java.lang.String name)
Checks if the name is likely available in Java as a package. A return value of true implies the name corresponds to a Java package, but does not guarantee that an import will succeed. A return value of false implies that an import from Java would fail, but does not guarantee that an import will fail. Note: A fully-qualified Java class name should return false since it is not a package name and the importer hook is expecting that.- Parameters:
name
- the name to check, such as java, java.util, java.util.ArrayList- Returns:
- true if it's likely a package supported by Java, false if it's likely a Python module (or a Java class name, or an invalid import)
-
getClassNames
java.lang.String[] getClassNames(java.lang.String pkgName)
Given a Java package name, gets the fully-qualified classnames available for import in the package. This method is primarily used for introspection using Python's dir() method. This method can return null if dir() support is not necessary.- Parameters:
pkgName
- the name of a package the ClassEnquirer supports, such as java.util- Returns:
- the list of classnames in the package, or null
-
getSubPackages
java.lang.String[] getSubPackages(java.lang.String pkgName)
Given a Java package name, gets the sub-packages available. For example, a sub-package of package "java" is "util", and a sub-package of package "java.util" is "concurrent". This method is primarily used for introspection using Python's dir() method. This method can return null if dir() support is not necessary.- Parameters:
pkgName
- the name of a package the ClassEnquirer supports, such as java.util- Returns:
- the list of sub-packages in the package, or null
-
-