@@ -185,20 +185,21 @@ vector<std::string> Universe::handleArguments(int32_t argc, char** argv) {
185185 vector<std::string> vmArgs = vector<std::string>();
186186 dumpBytecodes = 0 ;
187187 gcVerbosity = 0 ;
188+ bool sawOtherArgs = false ;
188189
189190 for (int32_t i = 1 ; i < argc; ++i) {
190- if (strncmp (argv[i], " -cp" , 3 ) == 0 ) {
191+ if (!sawOtherArgs && strncmp (argv[i], " -cp" , 3 ) == 0 ) {
191192 if ((argc == i + 1 ) || !classPath.empty ()) {
192193 printUsageAndExit (argv[0 ]);
193194 }
194195 setupClassPath (std::string (argv[++i]));
195- } else if (strncmp (argv[i], " -d" , 2 ) == 0 ) {
196+ } else if (!sawOtherArgs && strncmp (argv[i], " -d" , 2 ) == 0 ) {
196197 ++dumpBytecodes;
197- } else if (strncmp (argv[i], " -cfg" , 4 ) == 0 ) {
198+ } else if (!sawOtherArgs && strncmp (argv[i], " -cfg" , 4 ) == 0 ) {
198199 printVmConfig ();
199- } else if (strncmp (argv[i], " -g" , 2 ) == 0 ) {
200+ } else if (!sawOtherArgs && strncmp (argv[i], " -g" , 2 ) == 0 ) {
200201 ++gcVerbosity;
201- } else if (strncmp (argv[i], " -H" , 2 ) == 0 ) {
202+ } else if (!sawOtherArgs && strncmp (argv[i], " -H" , 2 ) == 0 ) {
202203 size_t heap_size = 0 ;
203204 char unit[3 ];
204205 // NOLINTNEXTLINE (cert-err34-c)
@@ -211,28 +212,30 @@ vector<std::string> Universe::handleArguments(int32_t argc, char** argv) {
211212 } else {
212213 printUsageAndExit (argv[0 ]);
213214 }
214-
215- } else if ((strncmp (argv[i], " -h" , 2 ) == 0 ) ||
216- (strncmp (argv[i], " --help" , 6 ) == 0 )) {
215+ } else if (!sawOtherArgs && ((strncmp (argv[i], " -h" , 2 ) == 0 ) ||
216+ (strncmp (argv[i], " --help" , 6 ) == 0 ))) {
217217 printUsageAndExit (argv[0 ]);
218- } else if ((strncmp (argv[i], " -prim-hash-check" , 16 )) == 0 ) {
218+ } else if (!sawOtherArgs &&
219+ (strncmp (argv[i], " -prim-hash-check" , 16 )) == 0 ) {
219220 abortOnCoreLibHashMismatch = true ;
220221 } else {
221- vector<std::string> extPathTokens = vector<std::string>(2 );
222+ sawOtherArgs = true ;
223+
222224 std::string const tmpString = std::string (argv[i]);
223- if (getClassPathExt (extPathTokens, tmpString)) {
224- addClassPath (extPathTokens[0 ]);
225- }
226- // Different from CSOM!!!:
227- // In CSOM there is an else, where the original filename is pushed
228- // into the vm_args. But unlike the class name in extPathTokens
229- // (extPathTokens[1]) that could still have the .som suffix though.
230- // So in SOM++ getClassPathExt will strip the suffix and add it to
231- // extPathTokens even if there is no new class path present. So we
232- // can in any case do the following:
233- vmArgs.push_back (extPathTokens[1 ]);
225+ vmArgs.push_back (tmpString);
226+ }
227+ }
228+
229+ if (!vmArgs.empty ()) {
230+ vector<std::string> extPathTokens = vector<std::string>(2 );
231+ std::string const firstArg = vmArgs[0 ];
232+ if (getClassPathExt (extPathTokens, firstArg)) {
233+ addClassPath (extPathTokens[0 ]);
234234 }
235+
236+ vmArgs[0 ] = extPathTokens[1 ];
235237 }
238+
236239 addClassPath (std::string (" ." ));
237240
238241 return vmArgs;
0 commit comments