< prev index next >

src/jdk.jpackage/share/native/libapplauncher/Package.cpp

Print this page




 175     TString debug;
 176     if (config->GetValue(keys[CONFIG_SECTION_APPLICATION],
 177             keys[CONFIG_APP_DEBUG], debug) == true) {
 178         FBootFields->FArgs.push_back(debug);
 179     }
 180 }
 181 
 182 void Package::Clear() {
 183     FreeBootFields();
 184     FInitialized = false;
 185 }
 186 
 187 // This is the only location that the AppCDS state should be modified except
 188 // by command line arguments provided by the user.
 189 //
 190 // The state of AppCDS is as follows:
 191 //
 192 // -> cdsUninitialized
 193 //    -> cdsGenCache If -Xappcds:generatecache
 194 //    -> cdsDisabled If -Xappcds:off
 195 //    -> cdsEnabled If "AppCDSJVMOptions" section is present
 196 //    -> cdsAuto If "AppCDSJVMOptions" section is present and
 197 //               app.appcds.cache=auto
 198 //    -> cdsDisabled Default
 199 //
 200 void Package::PromoteAppCDSState(ISectionalPropertyContainer* Config) {
 201     Platform& platform = Platform::GetInstance();
 202     std::map<TString, TString> keys = platform.GetKeys();
 203 
 204     // The AppCDS state can change at this point.
 205     switch (platform.GetAppCDSState()) {
 206         case cdsEnabled:
 207         case cdsAuto:
 208         case cdsDisabled:
 209         case cdsGenCache: {
 210             // Do nothing.
 211             break;
 212         }
 213 
 214         case cdsUninitialized: {
 215             if (Config->ContainsSection(
 216                     keys[CONFIG_SECTION_APPCDSJVMOPTIONS]) == true) {
 217                 // If the AppCDS section is present then enable AppCDS.
 218                 TString appCDSCacheValue;
 219 
 220                 // If running with AppCDS enabled, and the configuration has
 221                 // been setup so "auto" is enabled, then
 222                 // the launcher will attempt to generate the cache file
 223                 // automatically and run the application.
 224                 if (Config->GetValue(keys[CONFIG_SECTION_APPLICATION],
 225                         _T("app.appcds.cache"), appCDSCacheValue) == true &&
 226                     appCDSCacheValue == _T("auto")) {
 227                     platform.SetAppCDSState(cdsAuto);
 228                 }
 229                 else {
 230                     platform.SetAppCDSState(cdsEnabled);
 231                 }
 232             } else {
 233 
 234                 platform.SetAppCDSState(cdsDisabled);
 235             }
 236         }
 237     }
 238 }
 239 
 240 void Package::ReadJVMArgs(ISectionalPropertyContainer* Config) {
 241     Platform& platform = Platform::GetInstance();
 242     std::map<TString, TString> keys = platform.GetKeys();
 243 
 244     // Evaluate based on the current AppCDS state.
 245     switch (platform.GetAppCDSState()) {
 246         case cdsUninitialized: {
 247             throw Exception(_T("Internal Error"));
 248         }
 249 
 250         case cdsDisabled: {
 251             Config->GetSection(keys[CONFIG_SECTION_JVMOPTIONS],
 252                     FBootFields->FJVMArgs);
 253             break;
 254         }
 255 
 256         case cdsGenCache: {
 257             Config->GetSection(keys[
 258                     CONFIG_SECTION_APPCDSGENERATECACHEJVMOPTIONS],
 259                     FBootFields->FJVMArgs);
 260             break;
 261         }
 262 
 263         case cdsAuto:
 264         case cdsEnabled: {
 265             if (Config->GetValue(keys[CONFIG_SECTION_APPCDSJVMOPTIONS],
 266                     _T( "-XX:SharedArchiveFile"),
 267                     FBootFields->FAppCDSCacheFileName) == true) {
 268                 // File names may contain the incorrect path separators.
 269                 // The cache file name must be corrected at this point.
 270                 if (FBootFields->FAppCDSCacheFileName.empty() == false) {
 271                     IniFile* iniConfig = dynamic_cast<IniFile*>(Config);
 272 
 273                     if (iniConfig != NULL) {
 274                         FBootFields->FAppCDSCacheFileName =
 275                                 FilePath::FixPathForPlatform(
 276                                 FBootFields->FAppCDSCacheFileName);
 277                         iniConfig->SetValue(keys[
 278                                 CONFIG_SECTION_APPCDSJVMOPTIONS],
 279                                 _T( "-XX:SharedArchiveFile"),
 280                                 FBootFields->FAppCDSCacheFileName);
 281                     }
 282                 }
 283 
 284                 Config->GetSection(keys[CONFIG_SECTION_APPCDSJVMOPTIONS],
 285                         FBootFields->FJVMArgs);
 286             }
 287 
 288             break;
 289         }
 290     }
 291 }
 292 
 293 void Package::SetCommandLineArguments(int argc, TCHAR* argv[]) {
 294     if (argc > 0) {
 295         std::list<TString> args;
 296 
 297         // Prepare app arguments. Skip value at index 0 -
 298         // this is path to executable.
 299         FBootFields->FCommandName = argv[0];
 300 
 301         // Path to executable is at 0 index so start at index 1.
 302         for (int index = 1; index < argc; index++) {
 303             TString arg = argv[index];
 304 




 175     TString debug;
 176     if (config->GetValue(keys[CONFIG_SECTION_APPLICATION],
 177             keys[CONFIG_APP_DEBUG], debug) == true) {
 178         FBootFields->FArgs.push_back(debug);
 179     }
 180 }
 181 
 182 void Package::Clear() {
 183     FreeBootFields();
 184     FInitialized = false;
 185 }
 186 
 187 // This is the only location that the AppCDS state should be modified except
 188 // by command line arguments provided by the user.
 189 //
 190 // The state of AppCDS is as follows:
 191 //
 192 // -> cdsUninitialized
 193 //    -> cdsGenCache If -Xappcds:generatecache
 194 //    -> cdsDisabled If -Xappcds:off
 195 //    -> cdsEnabled If "AppCDSJavaOptions" section is present
 196 //    -> cdsAuto If "AppCDSJavaOptions" section is present and
 197 //               app.appcds.cache=auto
 198 //    -> cdsDisabled Default
 199 //
 200 void Package::PromoteAppCDSState(ISectionalPropertyContainer* Config) {
 201     Platform& platform = Platform::GetInstance();
 202     std::map<TString, TString> keys = platform.GetKeys();
 203 
 204     // The AppCDS state can change at this point.
 205     switch (platform.GetAppCDSState()) {
 206         case cdsEnabled:
 207         case cdsAuto:
 208         case cdsDisabled:
 209         case cdsGenCache: {
 210             // Do nothing.
 211             break;
 212         }
 213 
 214         case cdsUninitialized: {
 215             if (Config->ContainsSection(
 216                     keys[CONFIG_SECTION_APPCDSJAVAOPTIONS]) == true) {
 217                 // If the AppCDS section is present then enable AppCDS.
 218                 TString appCDSCacheValue;
 219 
 220                 // If running with AppCDS enabled, and the configuration has
 221                 // been setup so "auto" is enabled, then
 222                 // the launcher will attempt to generate the cache file
 223                 // automatically and run the application.
 224                 if (Config->GetValue(keys[CONFIG_SECTION_APPLICATION],
 225                         _T("app.appcds.cache"), appCDSCacheValue) == true &&
 226                     appCDSCacheValue == _T("auto")) {
 227                     platform.SetAppCDSState(cdsAuto);
 228                 }
 229                 else {
 230                     platform.SetAppCDSState(cdsEnabled);
 231                 }
 232             } else {
 233 
 234                 platform.SetAppCDSState(cdsDisabled);
 235             }
 236         }
 237     }
 238 }
 239 
 240 void Package::ReadJVMArgs(ISectionalPropertyContainer* Config) {
 241     Platform& platform = Platform::GetInstance();
 242     std::map<TString, TString> keys = platform.GetKeys();
 243 
 244     // Evaluate based on the current AppCDS state.
 245     switch (platform.GetAppCDSState()) {
 246         case cdsUninitialized: {
 247             throw Exception(_T("Internal Error"));
 248         }
 249 
 250         case cdsDisabled: {
 251             Config->GetSection(keys[CONFIG_SECTION_JAVAOPTIONS],
 252                     FBootFields->FJVMArgs);
 253             break;
 254         }
 255 
 256         case cdsGenCache: {
 257             Config->GetSection(keys[
 258                     CONFIG_SECTION_APPCDSGENERATECACHEJAVAOPTIONS],
 259                     FBootFields->FJVMArgs);
 260             break;
 261         }
 262 
 263         case cdsAuto:
 264         case cdsEnabled: {
 265             if (Config->GetValue(keys[CONFIG_SECTION_APPCDSJAVAOPTIONS],
 266                     _T( "-XX:SharedArchiveFile"),
 267                     FBootFields->FAppCDSCacheFileName) == true) {
 268                 // File names may contain the incorrect path separators.
 269                 // The cache file name must be corrected at this point.
 270                 if (FBootFields->FAppCDSCacheFileName.empty() == false) {
 271                     IniFile* iniConfig = dynamic_cast<IniFile*>(Config);
 272 
 273                     if (iniConfig != NULL) {
 274                         FBootFields->FAppCDSCacheFileName =
 275                                 FilePath::FixPathForPlatform(
 276                                 FBootFields->FAppCDSCacheFileName);
 277                         iniConfig->SetValue(keys[
 278                                 CONFIG_SECTION_APPCDSJAVAOPTIONS],
 279                                 _T( "-XX:SharedArchiveFile"),
 280                                 FBootFields->FAppCDSCacheFileName);
 281                     }
 282                 }
 283 
 284                 Config->GetSection(keys[CONFIG_SECTION_APPCDSJAVAOPTIONS],
 285                         FBootFields->FJVMArgs);
 286             }
 287 
 288             break;
 289         }
 290     }
 291 }
 292 
 293 void Package::SetCommandLineArguments(int argc, TCHAR* argv[]) {
 294     if (argc > 0) {
 295         std::list<TString> args;
 296 
 297         // Prepare app arguments. Skip value at index 0 -
 298         // this is path to executable.
 299         FBootFields->FCommandName = argv[0];
 300 
 301         // Path to executable is at 0 index so start at index 1.
 302         for (int index = 1; index < argc; index++) {
 303             TString arg = argv[index];
 304 


< prev index next >