Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/net/StreamExceptions.hpp
6000 views
1
/*******************************************************************************
2
* Copyright (c) 2018, 2021 IBM Corp. and others
3
*
4
* This program and the accompanying materials are made available under
5
* the terms of the Eclipse Public License 2.0 which accompanies this
6
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
7
* or the Apache License, Version 2.0 which accompanies this distribution and
8
* is available at https://www.apache.org/licenses/LICENSE-2.0.
9
*
10
* This Source Code may also be made available under the following
11
* Secondary Licenses when the conditions for such availability set
12
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
* General Public License, version 2 with the GNU Classpath
14
* Exception [1] and GNU General Public License, version 2 with the
15
* OpenJDK Assembly Exception [2].
16
*
17
* [1] https://www.gnu.org/software/classpath/license.html
18
* [2] http://openjdk.java.net/legal/assembly-exception.html
19
*
20
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
21
*******************************************************************************/
22
#ifndef STREAM_EXCEPTIONS_H
23
#define STREAM_EXCEPTIONS_H
24
25
#include <string>
26
#include "net/MessageTypes.hpp"
27
#include "infra/Assert.hpp"
28
29
namespace JITServer
30
{
31
class StreamFailure: public virtual std::exception
32
{
33
public:
34
StreamFailure() : _message("Generic stream failure") { }
35
StreamFailure(const std::string &message) : _message(message) { }
36
virtual const char* what() const throw() { return _message.c_str(); }
37
private:
38
std::string _message;
39
};
40
41
class StreamInterrupted: public virtual std::exception
42
{
43
public:
44
StreamInterrupted() { }
45
virtual const char* what() const throw()
46
{
47
return "Compilation interrupted at JITClient's request";
48
}
49
};
50
51
class StreamConnectionTerminate: public virtual std::exception
52
{
53
public:
54
StreamConnectionTerminate() { }
55
virtual const char* what() const throw()
56
{
57
return "Connection terminated at JITClient's request";
58
}
59
};
60
61
class StreamClientSessionTerminate: public virtual std::exception
62
{
63
public:
64
StreamClientSessionTerminate(uint64_t clientId) : _clientId(clientId)
65
{
66
_message = "JITClient session " + std::to_string(_clientId) + " terminated at JITClient's request";
67
}
68
virtual const char* what() const throw()
69
{
70
return _message.c_str();
71
}
72
uint64_t getClientId() const
73
{
74
return _clientId;
75
}
76
private:
77
std::string _message;
78
uint64_t _clientId;
79
};
80
81
class StreamOOO : public virtual std::exception
82
{
83
public:
84
virtual const char* what() const throw() { return "Messages arriving out-of-order"; }
85
};
86
87
class StreamTypeMismatch: public virtual StreamFailure
88
{
89
public:
90
StreamTypeMismatch(const std::string &message) : StreamFailure(message) { TR_ASSERT(false, "Type mismatch: %s", message.c_str()); }
91
};
92
93
class StreamMessageTypeMismatch: public virtual std::exception
94
{
95
public:
96
StreamMessageTypeMismatch() : _message("JITServer/JITClient message type mismatch detected") { }
97
StreamMessageTypeMismatch(MessageType serverType, MessageType clientType)
98
{
99
const char *expectedName = (serverType < MessageType_MAXTYPE) ? messageNames[serverType] : "";
100
const char *receivedName = (clientType < MessageType_MAXTYPE) ? messageNames[clientType] : "";
101
_message = "JITServer expected message type " + std::to_string(serverType) + " " + expectedName +
102
" received " + std::to_string(clientType) + " " + receivedName;
103
}
104
virtual const char* what() const throw()
105
{
106
return _message.c_str();
107
}
108
private:
109
std::string _message;
110
};
111
112
class StreamVersionIncompatible: public virtual std::exception
113
{
114
public:
115
StreamVersionIncompatible() : _message("JITServer/JITClient incompatibility detected") { }
116
StreamVersionIncompatible(uint64_t serverVersion, uint64_t clientVersion)
117
{
118
_message = "JITServer expected version " + std::to_string(serverVersion) + " received " + std::to_string(clientVersion);
119
}
120
virtual const char* what() const throw()
121
{
122
return _message.c_str();
123
}
124
private:
125
std::string _message;
126
};
127
128
class StreamArityMismatch: public virtual StreamFailure
129
{
130
public:
131
StreamArityMismatch(const std::string &message) : StreamFailure(message) { TR_ASSERT(false, "Arity mismatch: %s", message.c_str()); }
132
};
133
134
class ServerCompilationFailure: public virtual std::exception
135
{
136
public:
137
ServerCompilationFailure() : _message("Generic JITServer compilation failure") { }
138
ServerCompilationFailure(const std::string &message) : _message(message) { }
139
virtual const char* what() const throw() { return _message.c_str(); }
140
private:
141
std::string _message;
142
};
143
}
144
#endif // STREAM_EXCEPTIONS_H
145
146