Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/com/sun/tools/jdi/InternalEventHandler.java
38920 views
1
/*
2
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
package com.sun.tools.jdi;
27
28
import com.sun.jdi.*;
29
import com.sun.jdi.event.*;
30
import java.util.*;
31
32
public class InternalEventHandler implements Runnable
33
{
34
EventQueueImpl queue;
35
VirtualMachineImpl vm;
36
37
InternalEventHandler(VirtualMachineImpl vm, EventQueueImpl queue)
38
{
39
this.vm = vm;
40
this.queue = queue;
41
Thread thread = new Thread(vm.threadGroupForJDI(), this,
42
"JDI Internal Event Handler");
43
thread.setDaemon(true);
44
thread.start();
45
}
46
47
public void run() {
48
if ((vm.traceFlags & VirtualMachine.TRACE_EVENTS) != 0) {
49
vm.printTrace("Internal event handler running");
50
}
51
try {
52
while (true) {
53
try {
54
EventSet eventSet = queue.removeInternal();
55
EventIterator it = eventSet.eventIterator();
56
while (it.hasNext()) {
57
Event event = it.nextEvent();
58
if (event instanceof ClassUnloadEvent) {
59
ClassUnloadEvent cuEvent = (ClassUnloadEvent)event;
60
vm.removeReferenceType(cuEvent.classSignature());
61
62
if ((vm.traceFlags & VirtualMachine.TRACE_EVENTS) != 0) {
63
vm.printTrace("Handled Unload Event for " +
64
cuEvent.classSignature());
65
}
66
} else if (event instanceof ClassPrepareEvent) {
67
ClassPrepareEvent cpEvent = (ClassPrepareEvent)event;
68
((ReferenceTypeImpl)cpEvent.referenceType())
69
.markPrepared();
70
71
if ((vm.traceFlags & VirtualMachine.TRACE_EVENTS) != 0) {
72
vm.printTrace("Handled Prepare Event for " +
73
cpEvent.referenceType().name());
74
}
75
}
76
77
}
78
79
/*
80
* Handle exceptions that can occur in normal operation
81
* but which can't be accounted for by event builder
82
* methods. The thread should not be terminated if they
83
* occur.
84
*
85
* TO DO: We need a better way to log these conditions.
86
*/
87
} catch (VMOutOfMemoryException vmme) {
88
vmme.printStackTrace();
89
} catch (InconsistentDebugInfoException idie) {
90
idie.printStackTrace();
91
92
/*
93
* If any of these exceptions below occurs, there is some
94
* sort of programming error that should be addressed in
95
* the JDI implemementation. However, it would cripple
96
* the implementation if we let this thread die due to
97
* one of them. So, a notification of the exception is
98
* given and we attempt to continue.
99
*/
100
} catch (ObjectCollectedException oce) {
101
oce.printStackTrace();
102
} catch (ClassNotPreparedException cnpe) {
103
cnpe.printStackTrace();
104
}
105
}
106
} catch (InterruptedException e) { // should we really die here
107
} catch (VMDisconnectedException e) { // time to die
108
}
109
if ((vm.traceFlags & VirtualMachine.TRACE_EVENTS) != 0) {
110
vm.printTrace("Internal event handler exiting");
111
}
112
}
113
}
114
115