Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
26b463b3
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
26b463b3
编写于
3月 12, 2009
作者:
R
rupashka
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
Reviewed-by: peterz, loneid
上级
5f55e0e8
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
720 addition
and
451 deletion
+720
-451
src/share/classes/javax/swing/plaf/basic/BasicDirectoryModel.java
...e/classes/javax/swing/plaf/basic/BasicDirectoryModel.java
+91
-88
src/share/classes/sun/awt/shell/ShellFolder.java
src/share/classes/sun/awt/shell/ShellFolder.java
+30
-0
src/share/classes/sun/awt/shell/ShellFolderManager.java
src/share/classes/sun/awt/shell/ShellFolderManager.java
+16
-1
src/share/classes/sun/swing/FilePane.java
src/share/classes/sun/swing/FilePane.java
+11
-0
src/windows/classes/sun/awt/shell/Win32ShellFolder2.java
src/windows/classes/sun/awt/shell/Win32ShellFolder2.java
+409
-251
src/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java
...ndows/classes/sun/awt/shell/Win32ShellFolderManager2.java
+101
-0
src/windows/native/sun/windows/ShellFolder2.cpp
src/windows/native/sun/windows/ShellFolder2.cpp
+42
-111
test/javax/swing/JFileChooser/6570445/bug6570445.java
test/javax/swing/JFileChooser/6570445/bug6570445.java
+20
-0
未找到文件。
src/share/classes/javax/swing/plaf/basic/BasicDirectoryModel.java
浏览文件 @
26b463b3
...
...
@@ -27,6 +27,7 @@ package javax.swing.plaf.basic;
import
java.io.File
;
import
java.util.*
;
import
java.util.concurrent.Callable
;
import
javax.swing.*
;
import
javax.swing.filechooser.*
;
import
javax.swing.event.*
;
...
...
@@ -223,113 +224,115 @@ public class BasicDirectoryModel extends AbstractListModel implements PropertyCh
this
.
fid
=
fid
;
}
private
void
invokeLater
(
DoChangeContents
runnable
)
{
runnables
.
addElement
(
runnable
);
SwingUtilities
.
invokeLater
(
runnable
);
}
public
void
run
()
{
run0
();
setBusy
(
false
,
fid
);
}
public
void
run0
()
{
FileSystemView
fileSystem
=
filechooser
.
getFileSystemView
();
DoChangeContents
doChangeContents
=
ShellFolder
.
getInvoker
().
invoke
(
new
Callable
<
DoChangeContents
>()
{
public
DoChangeContents
call
()
throws
Exception
{
FileSystemView
fileSystem
=
filechooser
.
getFileSystemView
();
File
[]
list
=
fileSystem
.
getFiles
(
currentDirectory
,
filechooser
.
isFileHidingEnabled
());
File
[]
list
=
fileSystem
.
getFiles
(
currentDirectory
,
filechooser
.
isFileHidingEnabled
());
Vector
<
File
>
acceptsList
=
new
Vector
<
File
>();
Vector
<
File
>
acceptsList
=
new
Vector
<
File
>();
if
(
isInterrupted
())
{
return
;
}
if
(
isInterrupted
())
{
return
null
;
}
// run through the file list, add directories and selectable files to fileCache
for
(
File
file
:
list
)
{
if
(
filechooser
.
accept
(
file
))
{
acceptsList
.
addElement
(
file
);
}
}
// run through the file list, add directories and selectable files to fileCache
for
(
File
file
:
list
)
{
if
(
filechooser
.
accept
(
file
))
{
acceptsList
.
addElement
(
file
);
}
}
if
(
isInterrupted
())
{
return
;
}
if
(
isInterrupted
())
{
return
null
;
}
// First sort alphabetically by filename
sort
(
acceptsList
);
Vector
<
File
>
newDirectories
=
new
Vector
<
File
>(
50
);
Vector
<
File
>
newFiles
=
new
Vector
<
File
>();
// run through list grabbing directories in chunks of ten
for
(
int
i
=
0
;
i
<
acceptsList
.
size
();
i
++)
{
File
f
=
acceptsList
.
elementAt
(
i
);
boolean
isTraversable
=
filechooser
.
isTraversable
(
f
);
if
(
isTraversable
)
{
newDirectories
.
addElement
(
f
);
}
else
if
(!
isTraversable
&&
filechooser
.
isFileSelectionEnabled
())
{
newFiles
.
addElement
(
f
);
}
if
(
isInterrupted
())
{
return
;
}
}
// First sort alphabetically by filename
sort
(
acceptsList
);
Vector
<
File
>
newDirectories
=
new
Vector
<
File
>(
50
);
Vector
<
File
>
newFiles
=
new
Vector
<
File
>();
// run through list grabbing directories in chunks of ten
for
(
int
i
=
0
;
i
<
acceptsList
.
size
();
i
++)
{
File
f
=
acceptsList
.
elementAt
(
i
);
boolean
isTraversable
=
filechooser
.
isTraversable
(
f
);
if
(
isTraversable
)
{
newDirectories
.
addElement
(
f
);
}
else
if
(!
isTraversable
&&
filechooser
.
isFileSelectionEnabled
())
{
newFiles
.
addElement
(
f
);
}
if
(
isInterrupted
())
{
return
null
;
}
}
Vector
<
File
>
newFileCache
=
new
Vector
<
File
>(
newDirectories
);
newFileCache
.
addAll
(
newFiles
);
int
newSize
=
newFileCache
.
size
();
int
oldSize
=
fileCache
.
size
();
if
(
newSize
>
oldSize
)
{
//see if interval is added
int
start
=
oldSize
;
int
end
=
newSize
;
for
(
int
i
=
0
;
i
<
oldSize
;
i
++)
{
if
(!
newFileCache
.
get
(
i
).
equals
(
fileCache
.
get
(
i
)))
{
start
=
i
;
for
(
int
j
=
i
;
j
<
newSize
;
j
++)
{
if
(
newFileCache
.
get
(
j
).
equals
(
fileCache
.
get
(
i
)))
{
end
=
j
;
Vector
<
File
>
newFileCache
=
new
Vector
<
File
>(
newDirectories
);
newFileCache
.
addAll
(
newFiles
);
int
newSize
=
newFileCache
.
size
();
int
oldSize
=
fileCache
.
size
();
if
(
newSize
>
oldSize
)
{
//see if interval is added
int
start
=
oldSize
;
int
end
=
newSize
;
for
(
int
i
=
0
;
i
<
oldSize
;
i
++)
{
if
(!
newFileCache
.
get
(
i
).
equals
(
fileCache
.
get
(
i
)))
{
start
=
i
;
for
(
int
j
=
i
;
j
<
newSize
;
j
++)
{
if
(
newFileCache
.
get
(
j
).
equals
(
fileCache
.
get
(
i
)))
{
end
=
j
;
break
;
}
}
break
;
}
}
break
;
}
}
if
(
start
>=
0
&&
end
>
start
&&
newFileCache
.
subList
(
end
,
newSize
).
equals
(
fileCache
.
subList
(
start
,
oldSize
)))
{
if
(
isInterrupted
())
{
return
;
}
invokeLater
(
new
DoChangeContents
(
newFileCache
.
subList
(
start
,
end
),
start
,
null
,
0
,
fid
));
newFileCache
=
null
;
}
}
else
if
(
newSize
<
oldSize
)
{
//see if interval is removed
int
start
=
-
1
;
int
end
=
-
1
;
for
(
int
i
=
0
;
i
<
newSize
;
i
++)
{
if
(!
newFileCache
.
get
(
i
).
equals
(
fileCache
.
get
(
i
)))
{
start
=
i
;
end
=
i
+
oldSize
-
newSize
;
break
;
if
(
start
>=
0
&&
end
>
start
&&
newFileCache
.
subList
(
end
,
newSize
).
equals
(
fileCache
.
subList
(
start
,
oldSize
)))
{
if
(
isInterrupted
())
{
return
null
;
}
return
new
DoChangeContents
(
newFileCache
.
subList
(
start
,
end
),
start
,
null
,
0
,
fid
);
}
}
else
if
(
newSize
<
oldSize
)
{
//see if interval is removed
int
start
=
-
1
;
int
end
=
-
1
;
for
(
int
i
=
0
;
i
<
newSize
;
i
++)
{
if
(!
newFileCache
.
get
(
i
).
equals
(
fileCache
.
get
(
i
)))
{
start
=
i
;
end
=
i
+
oldSize
-
newSize
;
break
;
}
}
if
(
start
>=
0
&&
end
>
start
&&
fileCache
.
subList
(
end
,
oldSize
).
equals
(
newFileCache
.
subList
(
start
,
newSize
)))
{
if
(
isInterrupted
())
{
return
null
;
}
return
new
DoChangeContents
(
null
,
0
,
new
Vector
(
fileCache
.
subList
(
start
,
end
)),
start
,
fid
);
}
}
}
if
(
start
>=
0
&&
end
>
start
&&
fileCache
.
subList
(
end
,
oldSize
).
equals
(
newFileCache
.
subList
(
start
,
newSize
)))
{
if
(
isInterrupted
())
{
return
;
if
(!
fileCache
.
equals
(
newFileCache
))
{
if
(
isInterrupted
())
{
cancelRunnables
(
runnables
);
}
return
new
DoChangeContents
(
newFileCache
,
0
,
fileCache
,
0
,
fid
)
;
}
invokeLater
(
new
DoChangeContents
(
null
,
0
,
new
Vector
<
File
>(
fileCache
.
subList
(
start
,
end
)),
start
,
fid
));
newFileCache
=
null
;
}
}
if
(
newFileCache
!=
null
&&
!
fileCache
.
equals
(
newFileCache
))
{
if
(
isInterrupted
())
{
cancelRunnables
(
runnables
);
return
null
;
}
invokeLater
(
new
DoChangeContents
(
newFileCache
,
0
,
fileCache
,
0
,
fid
));
});
if
(
doChangeContents
!=
null
)
{
runnables
.
addElement
(
doChangeContents
);
SwingUtilities
.
invokeLater
(
doChangeContents
);
}
}
...
...
src/share/classes/sun/awt/shell/ShellFolder.java
浏览文件 @
26b463b3
...
...
@@ -31,6 +31,7 @@ import java.awt.Toolkit;
import
java.io.*
;
import
java.io.FileNotFoundException
;
import
java.util.*
;
import
java.util.concurrent.Callable
;
/**
* @author Michael Martak
...
...
@@ -461,6 +462,35 @@ public abstract class ShellFolder extends File {
return
null
;
}
private
static
Invoker
invoker
;
/**
* Provides the single access point to the {@link Invoker}. It is guaranteed that the value
* returned by this method will be always the same.
*
* @return the singleton instance of {@link Invoker}
*/
public
static
Invoker
getInvoker
()
{
if
(
invoker
==
null
)
{
invoker
=
shellFolderManager
.
createInvoker
();
}
return
invoker
;
}
/**
* Interface allowing to invoke tasks in different environments on different platforms.
*/
public
static
interface
Invoker
{
/**
* Invokes a callable task. If the {@code task} throws a checked exception,
* it will be wrapped into a {@link RuntimeException}
*
* @param task a task to invoke
* @return the result of {@code task}'s invokation
*/
<
T
>
T
invoke
(
Callable
<
T
>
task
);
}
/**
* Provides a default comparator for the default column set
*/
...
...
src/share/classes/sun/awt/shell/ShellFolderManager.java
浏览文件 @
26b463b3
...
...
@@ -27,6 +27,7 @@ package sun.awt.shell;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.util.concurrent.Callable
;
/**
* @author Michael Martak
...
...
@@ -96,9 +97,23 @@ class ShellFolderManager {
}
public
boolean
isFileSystemRoot
(
File
dir
)
{
if
(
dir
instanceof
ShellFolder
&&
!((
ShellFolder
)
dir
).
isFileSystem
())
{
if
(
dir
instanceof
ShellFolder
&&
!((
ShellFolder
)
dir
).
isFileSystem
())
{
return
false
;
}
return
(
dir
.
getParentFile
()
==
null
);
}
protected
ShellFolder
.
Invoker
createInvoker
()
{
return
new
DirectInvoker
();
}
private
static
class
DirectInvoker
implements
ShellFolder
.
Invoker
{
public
<
T
>
T
invoke
(
Callable
<
T
>
task
)
{
try
{
return
task
.
call
();
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
}
src/share/classes/sun/swing/FilePane.java
浏览文件 @
26b463b3
...
...
@@ -34,6 +34,7 @@ import java.text.DateFormat;
import
java.text.MessageFormat
;
import
java.util.*
;
import
java.util.List
;
import
java.util.concurrent.Callable
;
import
javax.swing.*
;
import
javax.swing.border.*
;
...
...
@@ -900,6 +901,16 @@ public class FilePane extends JPanel implements PropertyChangeListener {
}
}
@Override
public
void
sort
()
{
ShellFolder
.
getInvoker
().
invoke
(
new
Callable
<
Void
>()
{
public
Void
call
()
throws
Exception
{
DetailsTableRowSorter
.
super
.
sort
();
return
null
;
}
});
}
public
void
modelStructureChanged
()
{
super
.
modelStructureChanged
();
updateComparators
(
detailsTableModel
.
getColumns
());
...
...
src/windows/classes/sun/awt/shell/Win32ShellFolder2.java
浏览文件 @
26b463b3
此差异已折叠。
点击以展开。
src/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java
浏览文件 @
26b463b3
...
...
@@ -31,7 +31,10 @@ import java.io.File;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
java.security.AccessController
;
import
java.security.PrivilegedAction
;
import
java.util.*
;
import
java.util.concurrent.*
;
import
sun.security.action.LoadLibraryAction
;
import
static
sun
.
awt
.
shell
.
Win32ShellFolder2
.*;
...
...
@@ -408,4 +411,102 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
return
name1
.
compareTo
(
name2
);
}
}
@Override
protected
Invoker
createInvoker
()
{
return
new
ComInvoker
();
}
private
static
class
ComInvoker
extends
ThreadPoolExecutor
implements
ThreadFactory
,
ShellFolder
.
Invoker
{
private
static
Thread
comThread
;
private
ComInvoker
()
{
super
(
1
,
1
,
0
,
TimeUnit
.
DAYS
,
new
LinkedBlockingQueue
<
Runnable
>());
allowCoreThreadTimeOut
(
false
);
setThreadFactory
(
this
);
final
Runnable
shutdownHook
=
new
Runnable
()
{
public
void
run
()
{
AccessController
.
doPrivileged
(
new
PrivilegedAction
<
Void
>()
{
public
Void
run
()
{
shutdownNow
();
return
null
;
}
});
}
};
AccessController
.
doPrivileged
(
new
PrivilegedAction
<
Void
>()
{
public
Void
run
()
{
Runtime
.
getRuntime
().
addShutdownHook
(
new
Thread
(
shutdownHook
)
);
return
null
;
}
});
}
public
synchronized
Thread
newThread
(
final
Runnable
task
)
{
final
Runnable
comRun
=
new
Runnable
()
{
public
void
run
()
{
try
{
initializeCom
();
task
.
run
();
}
finally
{
uninitializeCom
();
}
}
};
comThread
=
AccessController
.
doPrivileged
(
new
PrivilegedAction
<
Thread
>()
{
public
Thread
run
()
{
/* The thread must be a member of a thread group
* which will not get GCed before VM exit.
* Make its parent the top-level thread group.
*/
ThreadGroup
tg
=
Thread
.
currentThread
().
getThreadGroup
();
for
(
ThreadGroup
tgn
=
tg
;
tgn
!=
null
;
tg
=
tgn
,
tgn
=
tg
.
getParent
());
Thread
thread
=
new
Thread
(
tg
,
comRun
,
"Swing-Shell"
);
thread
.
setDaemon
(
true
);
return
thread
;
}
}
);
return
comThread
;
}
public
<
T
>
T
invoke
(
Callable
<
T
>
task
)
{
try
{
T
result
;
if
(
Thread
.
currentThread
()
==
comThread
)
{
// if it's already called from the COM
// thread, we don't need to delegate the task
result
=
task
.
call
();
}
else
{
Future
<
T
>
future
=
submit
(
task
);
try
{
result
=
future
.
get
();
}
catch
(
InterruptedException
e
)
{
result
=
null
;
future
.
cancel
(
true
);
}
}
return
result
;
}
catch
(
Exception
e
)
{
Throwable
cause
=
(
e
instanceof
ExecutionException
)
?
e
.
getCause
()
:
e
;
if
(
cause
instanceof
RuntimeException
)
{
throw
(
RuntimeException
)
cause
;
}
if
(
cause
instanceof
Error
)
{
throw
(
Error
)
cause
;
}
throw
new
RuntimeException
(
cause
);
}
}
}
static
native
void
initializeCom
();
static
native
void
uninitializeCom
();
}
src/windows/native/sun/windows/ShellFolder2.cpp
浏览文件 @
26b463b3
...
...
@@ -225,6 +225,34 @@ JNIEXPORT void JNICALL Java_sun_awt_shell_Win32ShellFolder2_initIDs
FID_folderType
=
env
->
GetFieldID
(
cls
,
"folderType"
,
"Ljava/lang/String;"
);
}
/*
* Class: sun_awt_shell_Win32ShellFolderManager2
* Method: initializeCom
* Signature: ()V
*/
JNIEXPORT
void
JNICALL
Java_sun_awt_shell_Win32ShellFolderManager2_initializeCom
(
JNIEnv
*
env
,
jclass
cls
)
{
HRESULT
hr
=
::
CoInitialize
(
NULL
);
if
(
FAILED
(
hr
))
{
char
c
[
64
];
sprintf
(
c
,
"Could not initialize COM: HRESULT=0x%08X"
,
hr
);
JNU_ThrowInternalError
(
env
,
c
);
}
}
/*
* Class: sun_awt_shell_Win32ShellFolderManager2
* Method: uninitializeCom
* Signature: ()V
*/
JNIEXPORT
void
JNICALL
Java_sun_awt_shell_Win32ShellFolderManager2_uninitializeCom
(
JNIEnv
*
env
,
jclass
cls
)
{
::
CoUninitialize
();
}
static
IShellIcon
*
getIShellIcon
(
IShellFolder
*
pIShellFolder
)
{
// http://msdn.microsoft.com/library/en-us/shellcc/platform/Shell/programmersguide/shell_int/shell_int_programming/std_ifaces.asp
HRESULT
hres
;
...
...
@@ -239,29 +267,6 @@ static IShellIcon* getIShellIcon(IShellFolder* pIShellFolder) {
return
(
IShellIcon
*
)
NULL
;
}
// Fixed 6263669
//
// CoInitialize wrapper
// call CoInitialize to initialize COM in STA mode and check result
// RPC_E_CHANGED_MODE means COM has already been initialized in MTA mode,
// so don't set the flag to call CoUninitialize later
BOOL
CoInit
(
BOOL
&
doCoUninit
)
{
// returns TRUE if initialized successfully
switch
(
::
CoInitialize
(
NULL
))
{
case
S_OK
:
case
S_FALSE
:
doCoUninit
=
TRUE
;
return
TRUE
;
break
;
case
RPC_E_CHANGED_MODE
:
doCoUninit
=
FALSE
;
return
TRUE
;
break
;
default:
return
FALSE
;
}
}
/*
* Class: sun_awt_shell_Win32ShellFolder2
...
...
@@ -507,10 +512,10 @@ JNIEXPORT jint JNICALL Java_sun_awt_shell_Win32ShellFolder2_getAttributes0
/*
* Class: sun_awt_shell_Win32ShellFolder2
* Method: getFileSystemPath
* Method: getFileSystemPath
0
* Signature: (I)Ljava/lang/String;
*/
JNIEXPORT
jstring
JNICALL
Java_sun_awt_shell_Win32ShellFolder2_getFileSystemPath
__I
JNIEXPORT
jstring
JNICALL
Java_sun_awt_shell_Win32ShellFolder2_getFileSystemPath
0
(
JNIEnv
*
env
,
jclass
cls
,
jint
csidl
)
{
LPITEMIDLIST
relPIDL
;
...
...
@@ -611,18 +616,6 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_bindToObject
if
(
SUCCEEDED
(
hr
))
{
return
(
jlong
)
pFolder
;
}
if
(
IS_WINVISTA
)
{
BOOL
doCoUninit
;
if
(
CoInit
(
doCoUninit
))
{
hr
=
pParent
->
BindToObject
(
pidl
,
NULL
,
IID_IShellFolder
,
(
void
**
)
&
pFolder
);
if
(
doCoUninit
)
{
::
CoUninitialize
();
}
if
(
SUCCEEDED
(
hr
))
{
return
(
jlong
)
pFolder
;
}
}
}
return
0
;
}
...
...
@@ -650,7 +643,10 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_getLinkLocation
return
NULL
;
}
pParent
->
GetDisplayNameOf
(
pidl
,
SHGDN_NORMAL
|
SHGDN_FORPARSING
,
&
strret
);
hres
=
pParent
->
GetDisplayNameOf
(
pidl
,
SHGDN_NORMAL
|
SHGDN_FORPARSING
,
&
strret
);
if
(
FAILED
(
hres
))
{
return
NULL
;
}
switch
(
strret
.
uType
)
{
case
STRRET_CSTR
:
...
...
@@ -669,10 +665,6 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_getLinkLocation
break
;
}
BOOL
doCoUninit
;
if
(
!
CoInit
(
doCoUninit
))
{
return
0
;
}
IShellLinkW
*
psl
;
hres
=
::
CoCreateInstance
(
CLSID_ShellLink
,
NULL
,
CLSCTX_INPROC_SERVER
,
IID_IShellLinkW
,
(
LPVOID
*
)
&
psl
);
if
(
SUCCEEDED
(
hres
))
{
...
...
@@ -692,9 +684,6 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_getLinkLocation
}
psl
->
Release
();
}
if
(
doCoUninit
)
{
::
CoUninitialize
();
}
if
(
SUCCEEDED
(
hres
))
{
return
(
jlong
)
pidl
;
...
...
@@ -741,7 +730,7 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_parseDisplayName0
/*
* Class: sun_awt_shell_Win32ShellFolder2
* Method: getDisplayNameOf
* Signature: (JJ)Ljava/lang/String;
* Signature: (JJ
I
)Ljava/lang/String;
*/
JNIEXPORT
jstring
JNICALL
Java_sun_awt_shell_Win32ShellFolder2_getDisplayNameOf
(
JNIEnv
*
env
,
jclass
cls
,
jlong
parentIShellFolder
,
jlong
relativePIDL
,
jint
attrs
)
...
...
@@ -833,10 +822,6 @@ JNIEXPORT jint JNICALL Java_sun_awt_shell_Win32ShellFolder2_getIconIndex
}
INT
index
=
-
1
;
BOOL
doCoUninit
;
if
(
!
CoInit
(
doCoUninit
))
{
return
(
jint
)
index
;
}
HRESULT
hres
;
// http://msdn.microsoft.com/library/en-us/shellcc/platform/Shell/programmersguide/shell_int/shell_int_programming/std_ifaces.asp
...
...
@@ -844,9 +829,6 @@ JNIEXPORT jint JNICALL Java_sun_awt_shell_Win32ShellFolder2_getIconIndex
hres
=
pIShellIcon
->
GetIconOf
(
pidl
,
GIL_FORSHELL
,
&
index
);
}
if
(
doCoUninit
)
{
::
CoUninitialize
();
}
return
(
jint
)
index
;
}
...
...
@@ -866,10 +848,6 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_extractIcon
}
HICON
hIcon
=
NULL
;
BOOL
doCoUninit
;
if
(
!
CoInit
(
doCoUninit
))
{
return
(
jlong
)
hIcon
;
}
HRESULT
hres
;
IExtractIconW
*
pIcon
;
...
...
@@ -894,9 +872,6 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_extractIcon
}
pIcon
->
Release
();
}
if
(
doCoUninit
)
{
::
CoUninitialize
();
}
return
(
jlong
)
hIcon
;
}
...
...
@@ -994,14 +969,10 @@ JNIEXPORT jintArray JNICALL Java_sun_awt_shell_Win32ShellFolder2_getFileChooserB
HINSTANCE
libComCtl32
;
HINSTANCE
libShell32
;
libShell32
=
LoadLibrary
(
TEXT
(
"shell32.dll"
));
if
(
libShell32
!=
NULL
)
{
long
osVersion
=
GetVersion
();
BOOL
isVista
=
(
!
(
osVersion
&
0x80000000
)
&&
(
LOBYTE
(
LOWORD
(
osVersion
))
>=
6
));
hBitmap
=
(
HBITMAP
)
LoadImage
(
libShell32
,
isVista
?
TEXT
(
"IDB_TB_SH_DEF_16"
)
:
MAKEINTRESOURCE
(
216
),
IS_WINVISTA
?
TEXT
(
"IDB_TB_SH_DEF_16"
)
:
MAKEINTRESOURCE
(
216
),
IMAGE_BITMAP
,
0
,
0
,
LR_CREATEDIBSECTION
);
}
if
(
hBitmap
==
NULL
)
{
...
...
@@ -1095,46 +1066,6 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_getIconResource
}
// Helper functions for workaround COM initialization:
static
HRESULT
GetDetailsOfFolder
(
IShellFolder2
*
folder
,
LPCITEMIDLIST
pidl
,
UINT
column
,
SHELLDETAILS
*
psd
)
{
HRESULT
hr
=
folder
->
GetDetailsOf
(
pidl
,
column
,
psd
);
if
(
IS_WINVISTA
&&
FAILED
(
hr
))
{
BOOL
doCoUninit
;
if
(
CoInit
(
doCoUninit
))
{
hr
=
folder
->
GetDetailsOf
(
pidl
,
column
,
psd
);
if
(
doCoUninit
)
{
::
CoUninitialize
();
}
}
}
return
hr
;
}
static
HRESULT
GetDetailsOf
(
IShellDetails
*
details
,
LPCITEMIDLIST
pidl
,
UINT
column
,
SHELLDETAILS
*
psd
)
{
HRESULT
hr
=
details
->
GetDetailsOf
(
pidl
,
column
,
psd
);
if
(
IS_WINVISTA
&&
FAILED
(
hr
))
{
BOOL
doCoUninit
;
if
(
CoInit
(
doCoUninit
))
{
hr
=
details
->
GetDetailsOf
(
pidl
,
column
,
psd
);
if
(
doCoUninit
)
{
::
CoUninitialize
();
}
}
}
return
hr
;
}
/*
* Helper function for creating Java column info object
*/
...
...
@@ -1187,7 +1118,7 @@ JNIEXPORT jobjectArray JNICALL
int
colNum
=
-
1
;
hr
=
S_OK
;
do
{
hr
=
GetDetailsOfFolder
(
pIShellFolder2
,
NULL
,
++
colNum
,
&
sd
);
hr
=
pIShellFolder2
->
GetDetailsOf
(
NULL
,
++
colNum
,
&
sd
);
}
while
(
SUCCEEDED
(
hr
));
jobjectArray
columns
=
...
...
@@ -1202,7 +1133,7 @@ JNIEXPORT jobjectArray JNICALL
colNum
=
0
;
hr
=
S_OK
;
while
(
SUCCEEDED
(
hr
))
{
hr
=
GetDetailsOfFolder
(
pIShellFolder2
,
NULL
,
colNum
,
&
sd
);
hr
=
pIShellFolder2
->
GetDetailsOf
(
NULL
,
colNum
,
&
sd
);
if
(
SUCCEEDED
(
hr
))
{
hr
=
pIShellFolder2
->
GetDefaultColumnState
(
colNum
,
&
csFlags
);
...
...
@@ -1232,7 +1163,7 @@ JNIEXPORT jobjectArray JNICALL
int
colNum
=
-
1
;
hr
=
S_OK
;
do
{
hr
=
GetDetailsOf
(
pIShellDetails
,
NULL
,
++
colNum
,
&
sd
);
hr
=
pIShellDetails
->
GetDetailsOf
(
NULL
,
++
colNum
,
&
sd
);
}
while
(
SUCCEEDED
(
hr
));
jobjectArray
columns
=
...
...
@@ -1246,7 +1177,7 @@ JNIEXPORT jobjectArray JNICALL
colNum
=
0
;
hr
=
S_OK
;
while
(
SUCCEEDED
(
hr
))
{
hr
=
GetDetailsOf
(
pIShellDetails
,
NULL
,
colNum
,
&
sd
);
hr
=
pIShellDetails
->
GetDetailsOf
(
NULL
,
colNum
,
&
sd
);
if
(
SUCCEEDED
(
hr
))
{
jobject
column
=
CreateColumnInfo
(
env
,
&
columnClass
,
&
columnConstructor
,
...
...
@@ -1288,7 +1219,7 @@ JNIEXPORT jobject JNICALL
if
(
SUCCEEDED
(
hr
))
{
// The folder exposes IShellFolder2 interface
IShellFolder2
*
pIShellFolder2
=
(
IShellFolder2
*
)
pIUnknown
;
hr
=
GetDetailsOfFolder
(
pIShellFolder2
,
pidl
,
(
UINT
)
columnIdx
,
&
sd
);
hr
=
pIShellFolder2
->
GetDetailsOf
(
pidl
,
(
UINT
)
columnIdx
,
&
sd
);
pIShellFolder2
->
Release
();
if
(
SUCCEEDED
(
hr
))
{
STRRET
strRet
=
sd
.
str
;
...
...
@@ -1300,7 +1231,7 @@ JNIEXPORT jobject JNICALL
if
(
SUCCEEDED
(
hr
))
{
// The folder exposes IShellDetails interface
IShellDetails
*
pIShellDetails
=
(
IShellDetails
*
)
pIUnknown
;
hr
=
GetDetailsOf
(
pIShellDetails
,
pidl
,
(
UINT
)
columnIdx
,
&
sd
);
hr
=
pIShellDetails
->
GetDetailsOf
(
pidl
,
(
UINT
)
columnIdx
,
&
sd
);
pIShellDetails
->
Release
();
if
(
SUCCEEDED
(
hr
))
{
STRRET
strRet
=
sd
.
str
;
...
...
test/javax/swing/JFileChooser/6570445/bug6570445.java
0 → 100644
浏览文件 @
26b463b3
/*
* @test
* @bug 6570445
* @summary Checks if Win32ShellFolder2's COM-using methods work under a security manager
* @author Leonid Popov
*/
import
javax.swing.filechooser.FileSystemView
;
public
class
bug6570445
{
public
static
void
main
(
String
[]
args
)
{
System
.
setSecurityManager
(
new
SecurityManager
());
// The next line of code forces FileSystemView to request data from Win32ShellFolder2,
// what causes an exception if a security manager installed (see the bug 6570445 description)
FileSystemView
.
getFileSystemView
().
getRoots
();
System
.
out
.
println
(
"Passed."
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录