@@ -3612,13 +3612,95 @@ jint Arguments::finalize_vm_init_args(SysClassPath* scp_p, bool scp_assembly_req
36123612 }
36133613
36143614 if (!UseJVMCIClassLoader) {
3615+ // Append resolved entries from lib/jvmci/parentClassLoader.classpath to boot class path
3616+ jio_snprintf (pathBuffer, sizeof (pathBuffer), " %s%slib%sjvmci%sparentClassLoader.classpath" , Arguments::get_java_home (), fileSep, fileSep, fileSep);
3617+ struct stat st;
3618+ if (os::stat (pathBuffer, &st) == 0 ) {
3619+ char * class_path = NEW_C_HEAP_ARRAY (char , st.st_size + 1 , mtInternal);
3620+ int file_handle = os::open (pathBuffer, 0 , 0 );
3621+ if (file_handle != -1 ) {
3622+ int class_path_len = (int ) os::read (file_handle, class_path, st.st_size );
3623+ // close file
3624+ os::close (file_handle);
3625+ if (class_path_len == st.st_size ) {
3626+ // Strip newline from end of file contents
3627+ char * p = class_path + class_path_len - 1 ;
3628+ while (p >= class_path && (*p == ' \r ' || *p == ' \n ' )) {
3629+ --p;
3630+ --class_path_len;
3631+ }
3632+
3633+ // Iterate over class path entries
3634+ int end = 0 ;
3635+ int entry_index = 0 ;
3636+ char path_sep = os::path_separator ()[0 ];
3637+ for (int start = 0 ; start < class_path_len; start = end) {
3638+ char entry[JVM_MAXPATHLEN];
3639+ int i = 0 ;
3640+ while (end < class_path_len && class_path[end] != path_sep) {
3641+ char ch = class_path[end];
3642+ if (i == 0 ) {
3643+ // Only paths starting with '\' will be considered
3644+ // absolute on Windows. The complete test for an absolute
3645+ // path on Windows is complex and not worth supporting
3646+ // for this feature.
3647+ bool is_absolute_path = ch == fileSep[0 ];
3648+ if (!is_absolute_path) {
3649+ // Prepend lib/jvmci dir for relative path
3650+ i = jio_snprintf (entry, sizeof (entry), " %s%slib%sjvmci%s" , Arguments::get_java_home (), fileSep, fileSep, fileSep);
3651+ }
3652+ }
3653+ if (i >= (int ) sizeof (entry) - 1 ) {
3654+ jio_fprintf (defaultStream::error_stream (),
3655+ " Resolving class path entry %d in %s exceeds %d characters (truncated value \" %s\" )\n " , entry_index, pathBuffer, sizeof (entry) - 2 , entry);
3656+ FREE_C_HEAP_ARRAY (char , class_path, mtInternal);
3657+ return JNI_ERR;
3658+ }
3659+ entry[i++] = ch;
3660+ end++;
3661+ }
3662+ entry[i++] = ' \0 ' ;
3663+
3664+ struct stat st2;
3665+ if (os::stat (entry, &st2) != 0 ) {
3666+ jio_fprintf (defaultStream::error_stream (),
3667+ " Resolved class path entry %d in %s does not refer to an existing file or directory" \
3668+ " (note: only class path entries starting with '%c' are interpreted as absolute): '%s'\n " , entry_index, pathBuffer, fileSep[0 ], entry);
3669+ FREE_C_HEAP_ARRAY (char , class_path, mtInternal);
3670+ return JNI_ERR;
3671+ }
3672+ scp_p->add_suffix (entry);
3673+ scp_assembly_required = true ;
3674+
3675+ while (class_path[end] == os::path_separator ()[0 ]) {
3676+ end++;
3677+ }
3678+ entry_index++;
3679+ }
3680+ FREE_C_HEAP_ARRAY (char , class_path, mtInternal);
3681+ } else {
3682+ jio_fprintf (defaultStream::error_stream (),
3683+ " Truncated read from %s (only read %d of %d bytes)\n " , pathBuffer, class_path_len, st.st_size );
3684+ FREE_C_HEAP_ARRAY (char , class_path, mtInternal);
3685+ return JNI_ERR;
3686+ }
3687+ } else {
3688+ jio_fprintf (defaultStream::error_stream (),
3689+ " Failed to open %s (%s)\n " , pathBuffer, strerror (errno));
3690+ FREE_C_HEAP_ARRAY (char , class_path, mtInternal);
3691+ return JNI_ERR;
3692+ }
3693+ }
3694+
36153695 // Append lib/jvmci/*.jar to boot class path
36163696 jio_snprintf (pathBuffer, sizeof (pathBuffer), " %s%slib%sjvmci" , Arguments::get_java_home (), fileSep, fileSep);
36173697 char * jvmci_path = SysClassPath::add_jars_to_path (NULL , pathBuffer);
36183698 if (jvmci_path != NULL ) {
36193699 scp_p->add_suffix (jvmci_path);
36203700 scp_assembly_required = true ;
36213701 }
3702+
3703+ // Append value of jvmci.class.path.append system property to boot class path
36223704 const char * path = Arguments::get_property (" jvmci.class.path.append" );
36233705 if (path != NULL ) {
36243706 scp_p->add_suffix (path);
0 commit comments