1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_jvmfwk.hxx"
26 
27 #include "osl/thread.h"
28 #include "sunjre.hxx"
29 #include "sunversion.hxx"
30 #include "diagnostics.h"
31 
32 using namespace rtl;
33 using namespace std;
34 
35 #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
36 namespace jfw_plugin
37 {
38 
39 Reference<VendorBase> SunInfo::createInstance()
40 {
41     return new SunInfo;
42 }
43 
44 char const* const* SunInfo::getJavaExePaths(int * size)
45 {
46     static char const * ar[] = {
47 #if defined(WNT) || defined(OS2)
48         "java.exe",
49         "bin/java.exe",
50         "jre/bin/java.exe"
51 #elif UNX
52         "java",
53         "bin/java",
54         "jre/bin/java"
55 #endif
56     };
57         *size = sizeof (ar) / sizeof (char*);
58     return ar;
59 }
60 
61 char const* const* SunInfo::getRuntimePaths(int * size)
62 {
63     static char const* ar[]= {
64 #if defined(WNT)
65         "/bin/client/jvm.dll",
66         "/bin/hotspot/jvm.dll",
67         "/bin/classic/jvm.dll"
68 #elif defined(OS2)
69         "/bin/classic/jvm.dll",
70 #elif UNX
71         "/lib/" JFW_PLUGIN_ARCH "/client/libjvm.so",
72         "/lib/" JFW_PLUGIN_ARCH "/server/libjvm.so",
73         "/lib/" JFW_PLUGIN_ARCH "/classic/libjvm.so"
74 #endif
75 
76     };
77     *size = sizeof(ar) / sizeof (char*);
78     return ar;
79 }
80 
81 char const* const* SunInfo::getLibraryPaths(int* size)
82 {
83 #ifdef UNX
84     static char const * ar[] = {
85 
86         "/lib/" JFW_PLUGIN_ARCH "/client",
87         "/lib/" JFW_PLUGIN_ARCH "/native_threads",
88         "/lib/" JFW_PLUGIN_ARCH
89 
90     };
91     *size = sizeof(ar) / sizeof (char*);
92     return ar;
93 #else
94     size = 0;
95     return NULL;
96 #endif
97 }
98 
99 int SunInfo::compareVersions(const rtl::OUString& sSecond) const
100 {
101     OUString sFirst = getVersion();
102 
103     SunVersion version1(sFirst);
104     JFW_ENSURE(version1, OUSTR("[Java framework] sunjavaplugin"SAL_DLLEXTENSION
105                                " does not know the version: ")
106                + sFirst + OUSTR(" as valid for a SUN JRE."));
107     SunVersion version2(sSecond);
108     if ( ! version2)
109         throw MalformedVersionException();
110 
111     if(version1 == version2)
112         return 0;
113     if(version1 > version2)
114         return 1;
115     else
116         return -1;
117 }
118 
119 
120 }
121