Class PackageInfoCache

java.lang.Object
com.google.j2cl.transpiler.frontend.common.PackageInfoCache

public class PackageInfoCache extends Object
A cache for information on package-info files that are needed for transpilation, like JsInterop annotations.

The cached information comes from two sources. It can either be extracted from previously compiled package-info.class files in the classpath or from package-info.java sources that are part of the current compile.

Requests are answered against the package-info file in the same package and same class path entry as the queried about type. To do anything else would lead to inconsistent answers when multiple class path entries contain the same packages but with different package info files, depending on what arbitrary set of class path entries do or do not happen to be included in the current compile.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Encapsulates all that is known about a particular package in a particular class path entry.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    When nothing is known about a particular package in a particular class path entry the answers to questions about package properties are taken from this instance.
    static final String
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
     
    get()
     
    getJsNamespace(String topLevelTypeSourceName)
    Returns the JsNamespace for the given type, which must be a top level type and referenced by fully qualified source name.
    getObjectiveCName(String topLevelTypeSourceName)
    Returns the ObjectiveCName for the given type which must be a top level type and referenced by its fully qualified source name.
    static void
    init(List<String> classPathEntries, com.google.j2cl.common.Problems problems)
     
    boolean
    isNullMarked(String topLevelTypeSourceName)
     
    void
    markAsSource(String topLevelTypeSourceName)
    Let the PackageInfoCache know that this class is Source, otherwise it would have to rummage around in the class path to figure it out and it might even come up with the wrong answer.
    void
    setPackageProperties(String classPathEntry, String packagePath, String packageJsNamespace, String objectiveCName, boolean isNullMarked)
    Specify the JavaScript namespace and whether it defines a null marked scope for a given package (as identified by the combination of class path entry and package path).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • SOURCE_CLASS_PATH_ENTRY

      public static final String SOURCE_CLASS_PATH_ENTRY
      See Also:
    • DEFAULT_PACKAGE_REPORT

      public static final PackageInfoCache.PackageReport DEFAULT_PACKAGE_REPORT
      When nothing is known about a particular package in a particular class path entry the answers to questions about package properties are taken from this instance.
  • Method Details

    • clear

      public static void clear()
    • get

      public static PackageInfoCache get()
    • init

      public static void init(List<String> classPathEntries, com.google.j2cl.common.Problems problems)
    • getJsNamespace

      public String getJsNamespace(String topLevelTypeSourceName)
      Returns the JsNamespace for the given type, which must be a top level type and referenced by fully qualified source name.
    • getObjectiveCName

      public String getObjectiveCName(String topLevelTypeSourceName)
      Returns the ObjectiveCName for the given type which must be a top level type and referenced by its fully qualified source name.
    • isNullMarked

      public boolean isNullMarked(String topLevelTypeSourceName)
    • markAsSource

      public void markAsSource(String topLevelTypeSourceName)
      Let the PackageInfoCache know that this class is Source, otherwise it would have to rummage around in the class path to figure it out and it might even come up with the wrong answer. For example if this class has also been globbed into some other library that is a dependency of this one.
    • setPackageProperties

      public void setPackageProperties(String classPathEntry, String packagePath, String packageJsNamespace, String objectiveCName, boolean isNullMarked)
      Specify the JavaScript namespace and whether it defines a null marked scope for a given package (as identified by the combination of class path entry and package path).