1647 /* 40 for -Denv.class.path= */ 1648 if (JLI_StrLen(s) + 40 > JLI_StrLen(s)) { // Safeguard from overflow 1649 envcp = (char *)JLI_MemAlloc(JLI_StrLen(s) + 40); 1650 sprintf(envcp, "-Denv.class.path=%s", s); 1651 AddOption(envcp, NULL); 1652 } 1653 } 1654 } 1655 1656 if (!GetApplicationHome(home, sizeof(home))) { 1657 JLI_ReportErrorMessage(CFG_ERROR5); 1658 return JNI_FALSE; 1659 } 1660 1661 /* 40 for '-Dapplication.home=' */ 1662 apphome = (char *)JLI_MemAlloc(JLI_StrLen(home) + 40); 1663 sprintf(apphome, "-Dapplication.home=%s", home); 1664 AddOption(apphome, NULL); 1665 1666 /* How big is the application's classpath? */ 1667 size = 40; /* 40: "-Djava.class.path=" */ 1668 for (i = 0; i < cpathc; i++) { 1669 size += (int)JLI_StrLen(home) + (int)JLI_StrLen(cpathv[i]) + 1; /* 1: separator */ 1670 } 1671 appcp = (char *)JLI_MemAlloc(size + 1); 1672 JLI_StrCpy(appcp, "-Djava.class.path="); 1673 for (i = 0; i < cpathc; i++) { 1674 JLI_StrCat(appcp, home); /* c:\program files\myapp */ 1675 JLI_StrCat(appcp, cpathv[i]); /* \lib\myapp.jar */ 1676 JLI_StrCat(appcp, separator); /* ; */ 1677 } 1678 appcp[JLI_StrLen(appcp)-1] = '\0'; /* remove trailing path separator */ 1679 AddOption(appcp, NULL); 1680 return JNI_TRUE; 1681 } 1682 1683 /* 1684 * inject the -Dsun.java.command pseudo property into the args structure 1685 * this pseudo property is used in the HotSpot VM to expose the 1686 * Java class name and arguments to the main method to the VM. The 1687 * HotSpot VM uses this pseudo property to store the Java class name 1688 * (or jar file name) and the arguments to the class's main method 1689 * to the instrumentation memory region. The sun.java.command pseudo 1690 * property is not exported by HotSpot to the Java layer. 1691 */ 1692 void 1693 SetJavaCommandLineProp(char *what, int argc, char **argv) 1694 { 1695 1696 int i = 0; 1697 size_t len = 0; 1698 char* javaCommand = NULL; 1699 char* dashDstr = "-Dsun.java.command="; | 1647 /* 40 for -Denv.class.path= */ 1648 if (JLI_StrLen(s) + 40 > JLI_StrLen(s)) { // Safeguard from overflow 1649 envcp = (char *)JLI_MemAlloc(JLI_StrLen(s) + 40); 1650 sprintf(envcp, "-Denv.class.path=%s", s); 1651 AddOption(envcp, NULL); 1652 } 1653 } 1654 } 1655 1656 if (!GetApplicationHome(home, sizeof(home))) { 1657 JLI_ReportErrorMessage(CFG_ERROR5); 1658 return JNI_FALSE; 1659 } 1660 1661 /* 40 for '-Dapplication.home=' */ 1662 apphome = (char *)JLI_MemAlloc(JLI_StrLen(home) + 40); 1663 sprintf(apphome, "-Dapplication.home=%s", home); 1664 AddOption(apphome, NULL); 1665 1666 /* How big is the application's classpath? */ 1667 if (cpathc > 0) { 1668 size = 40; /* 40: "-Djava.class.path=" */ 1669 for (i = 0; i < cpathc; i++) { 1670 size += (int)JLI_StrLen(home) + (int)JLI_StrLen(cpathv[i]) + 1; /* 1: separator */ 1671 } 1672 appcp = (char *)JLI_MemAlloc(size + 1); 1673 JLI_StrCpy(appcp, "-Djava.class.path="); 1674 for (i = 0; i < cpathc; i++) { 1675 JLI_StrCat(appcp, home); /* c:\program files\myapp */ 1676 JLI_StrCat(appcp, cpathv[i]); /* \lib\myapp.jar */ 1677 JLI_StrCat(appcp, separator); /* ; */ 1678 } 1679 appcp[JLI_StrLen(appcp)-1] = '\0'; /* remove trailing path separator */ 1680 AddOption(appcp, NULL); 1681 } 1682 return JNI_TRUE; 1683 } 1684 1685 /* 1686 * inject the -Dsun.java.command pseudo property into the args structure 1687 * this pseudo property is used in the HotSpot VM to expose the 1688 * Java class name and arguments to the main method to the VM. The 1689 * HotSpot VM uses this pseudo property to store the Java class name 1690 * (or jar file name) and the arguments to the class's main method 1691 * to the instrumentation memory region. The sun.java.command pseudo 1692 * property is not exported by HotSpot to the Java layer. 1693 */ 1694 void 1695 SetJavaCommandLineProp(char *what, int argc, char **argv) 1696 { 1697 1698 int i = 0; 1699 size_t len = 0; 1700 char* javaCommand = NULL; 1701 char* dashDstr = "-Dsun.java.command="; |