< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java

Print this page
*** 1,7 ***
  /*
!  * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.  Oracle designates this
--- 1,7 ---
  /*
!  * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.  Oracle designates this

*** 53,21 ***
  import com.sun.tools.javac.comp.Annotate;
  import com.sun.tools.javac.file.JRTIndex;
  import com.sun.tools.javac.file.JavacFileManager;
  import com.sun.tools.javac.jvm.ClassReader;
  import com.sun.tools.javac.jvm.Profile;
  import com.sun.tools.javac.main.Option;
- import com.sun.tools.javac.platform.PlatformDescription;
  import com.sun.tools.javac.resources.CompilerProperties.Fragments;
  import com.sun.tools.javac.util.*;
  
  import static javax.tools.StandardLocation.*;
  
  import static com.sun.tools.javac.code.Flags.*;
  import static com.sun.tools.javac.code.Kinds.Kind.*;
! import com.sun.tools.javac.code.Symbol;
- import com.sun.tools.javac.code.Symbol.CompletionFailure;
  import com.sun.tools.javac.main.DelegatingJavaFileManager;
  
  import com.sun.tools.javac.util.Dependencies.CompletionCause;
  
  /**
--- 53,20 ---
  import com.sun.tools.javac.comp.Annotate;
  import com.sun.tools.javac.file.JRTIndex;
  import com.sun.tools.javac.file.JavacFileManager;
  import com.sun.tools.javac.jvm.ClassReader;
  import com.sun.tools.javac.jvm.Profile;
+ import com.sun.tools.javac.main.JavaCompiler;
  import com.sun.tools.javac.main.Option;
  import com.sun.tools.javac.resources.CompilerProperties.Fragments;
  import com.sun.tools.javac.util.*;
  
  import static javax.tools.StandardLocation.*;
  
  import static com.sun.tools.javac.code.Flags.*;
  import static com.sun.tools.javac.code.Kinds.Kind.*;
! 
  import com.sun.tools.javac.main.DelegatingJavaFileManager;
  
  import com.sun.tools.javac.util.Dependencies.CompletionCause;
  
  /**

*** 216,11 ***
          if (fm instanceof JavacFileManager javacFileManager) {
              useCtProps = javacFileManager.isDefaultBootClassPath() && javacFileManager.isSymbolFileEnabled();
          } else {
              useCtProps = false;
          }
!         jrtIndex = useCtProps && JRTIndex.isAvailable() ? JRTIndex.getSharedInstance() : null;
  
          profile = Profile.instance(context);
          cachedCompletionFailure = new CompletionFailure(null, () -> null, dcfh);
          cachedCompletionFailure.setStackTrace(new StackTraceElement[0]);
      }
--- 215,18 ---
          if (fm instanceof JavacFileManager javacFileManager) {
              useCtProps = javacFileManager.isDefaultBootClassPath() && javacFileManager.isSymbolFileEnabled();
          } else {
              useCtProps = false;
          }
!         if (useCtProps && JRTIndex.isAvailable()) {
+             Preview preview = Preview.instance(context);
+             JavaCompiler comp = JavaCompiler.instance(context);
+             jrtIndex = JRTIndex.instance(preview.isEnabled());
+             comp.closeables = comp.closeables.prepend(jrtIndex);
+         } else {
+             jrtIndex = null;
+         }
  
          profile = Profile.instance(context);
          cachedCompletionFailure = new CompletionFailure(null, () -> null, dcfh);
          cachedCompletionFailure.setStackTrace(new StackTraceElement[0]);
      }
< prev index next >