readRuntimeClassPath function

List<String>? readRuntimeClassPath(
  1. JavaRuntimeSpec spec,
  2. Directory dir
)

The class path recorded in the runtime directory dir, absolute; null when there is none, it belongs to another runtime id, its provisioning failed verification ("verified": false in the manifest), or an entry is missing.

Implementation

List<String>? readRuntimeClassPath(JavaRuntimeSpec spec, Directory dir) {
  final manifest = File(joinPath([dir.path, JavaRuntimeSpec.manifestFileName]));
  if (manifest.existsSync()) {
    try {
      final decoded = jsonDecode(manifest.readAsStringSync());
      if (decoded is! Map ||
          (decoded['runtimeId'] ?? spec.runtimeId) != spec.runtimeId ||
          decoded['verified'] == false) {
        return null;
      }
    } on FormatException {
      return null;
    }
  }

  final entries = recordedClassPath(dir);
  if (entries == null) return null;
  for (final entry in entries) {
    if (!_exists(entry)) return null;
  }
  return entries;
}