Skip to content

Commit 057d8bd

Browse files
Make all symbols from ':common' public to have proper IDEA highlighting and completion
1 parent ebe108b commit 057d8bd

File tree

17 files changed

+69
-86
lines changed

17 files changed

+69
-86
lines changed

common/src/main/org/jetbrains/lincheck/descriptors/CodeLocations.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import org.jetbrains.lincheck.trace.TRACE_CONTEXT
1919
* along with their corresponding code locations. To minimize overhead, Lincheck assigns unique IDs to all
2020
* code locations it analyses, and stores more detailed information necessary for trace generation in this object.
2121
*/
22-
internal object CodeLocations {
22+
object CodeLocations {
2323
/**
2424
* Registers a new code location and returns its unique ID.
2525
*

common/src/main/org/jetbrains/lincheck/descriptors/MethodSignature.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ package org.jetbrains.lincheck.descriptors
1313
import org.objectweb.asm.commons.Method
1414

1515

16-
internal fun Method.toMethodSignature() = MethodSignature(this.name, Types.convertAsmMethodType(this.descriptor))
17-
internal fun java.lang.reflect.Method.toMethodSignature() = Method.getMethod(this).toMethodSignature()
16+
fun Method.toMethodSignature() = MethodSignature(this.name, Types.convertAsmMethodType(this.descriptor))
17+
fun java.lang.reflect.Method.toMethodSignature() = Method.getMethod(this).toMethodSignature()

common/src/main/org/jetbrains/lincheck/trace/IndexedPool.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
package org.jetbrains.lincheck.trace
1212

13-
internal class IndexedPool<T> {
14-
private val items = mutableListOf<T>()
13+
class IndexedPool<T> {
14+
private val items = mutableListOf<T?>()
1515
private val index = hashMapOf<T, Int>()
1616

1717
@Synchronized

common/src/main/org/jetbrains/lincheck/trace/TraceContext.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ import org.jetbrains.lincheck.descriptors.MethodSignature
1717
import org.jetbrains.lincheck.descriptors.VariableDescriptor
1818
import org.jetbrains.lincheck.descriptors.Types
1919

20-
internal val TRACE_CONTEXT: TraceContext = TraceContext()
20+
val TRACE_CONTEXT: TraceContext = TraceContext()
2121

22-
internal const val UNKNOWN_CODE_LOCATION_ID = -1
22+
const val UNKNOWN_CODE_LOCATION_ID = -1
2323

2424
private val EMPTY_STACK_TRACE = StackTraceElement("", "", "", 0)
2525

2626
class TraceContext {
27-
private val locations = ArrayList<StackTraceElement>()
27+
private val locations = ArrayList<StackTraceElement?>()
2828
private val classes = IndexedPool<ClassDescriptor>()
2929
private val methods = IndexedPool<MethodDescriptor>()
3030
private val fields = IndexedPool<FieldDescriptor>()

common/src/main/org/jetbrains/lincheck/util/AnalysisSections.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import sun.nio.ch.lincheck.ThreadDescriptor
4343
* Local sections: [NORMAL], [SILENT].
4444
* Propagating sections: [SILENT_PROPAGATING], [ATOMIC], [IGNORED].
4545
*/
46-
internal enum class AnalysisSectionType {
46+
enum class AnalysisSectionType {
4747

4848
/**
4949
* Normal section without special handling.
@@ -94,25 +94,25 @@ internal enum class AnalysisSectionType {
9494
IGNORED,
9595
}
9696

97-
internal fun AnalysisSectionType.isCallStackPropagating() =
97+
fun AnalysisSectionType.isCallStackPropagating() =
9898
this >= AnalysisSectionType.SILENT_PROPAGATING
9999

100-
internal fun AnalysisSectionType.isSilent() =
100+
fun AnalysisSectionType.isSilent() =
101101
this == AnalysisSectionType.SILENT ||
102102
this == AnalysisSectionType.SILENT_PROPAGATING
103103

104104

105105
/**
106106
* Enables analysis for the current thread.
107107
*/
108-
internal fun enableAnalysis() {
108+
fun enableAnalysis() {
109109
Injections.enableAnalysis()
110110
}
111111

112112
/**
113113
* Disables analysis for the current thread.
114114
*/
115-
internal fun disableAnalysis() {
115+
fun disableAnalysis() {
116116
Injections.disableAnalysis()
117117
}
118118

@@ -122,7 +122,7 @@ internal fun disableAnalysis() {
122122
* Does not affect the current thread if it is untracked
123123
* (e.g. not registered in the Lincheck strategy).
124124
*/
125-
internal fun enterIgnoredSection() {
125+
fun enterIgnoredSection() {
126126
Injections.enterIgnoredSection()
127127
}
128128

@@ -132,7 +132,7 @@ internal fun enterIgnoredSection() {
132132
* Does not affect the current thread if it is untracked
133133
* (e.g. not registered in the Lincheck strategy).
134134
*/
135-
internal fun leaveIgnoredSection() {
135+
fun leaveIgnoredSection() {
136136
Injections.leaveIgnoredSection()
137137
}
138138

@@ -146,7 +146,7 @@ internal fun leaveIgnoredSection() {
146146
* @param block the code to execute within the ignored section.
147147
* @return result of the [block] invocation.
148148
*/
149-
internal inline fun <R> runInsideIgnoredSection(block: () -> R): R {
149+
inline fun <R> runInsideIgnoredSection(block: () -> R): R {
150150
val desc = ThreadDescriptor.getCurrentThreadDescriptor() ?: return block()
151151
desc.enterIgnoredSection()
152152
try {
@@ -164,7 +164,7 @@ internal inline fun <R> runInsideIgnoredSection(block: () -> R): R {
164164
* @return result of [block] invocation.
165165
* @throws IllegalStateException if the method is called not from an ignored section.
166166
*/
167-
internal inline fun <R> runOutsideIgnoredSection(block: () -> R): R {
167+
inline fun <R> runOutsideIgnoredSection(block: () -> R): R {
168168
val descriptor = ThreadDescriptor.getCurrentThreadDescriptor()
169169
if (
170170
descriptor == null ||
@@ -196,7 +196,7 @@ internal inline fun <R> runOutsideIgnoredSection(block: () -> R): R {
196196
* standard collections and concurrent collections are hidden,
197197
* concurrent collections are muted.
198198
*/
199-
internal class AnalysisProfile(val analyzeStdLib: Boolean) {
199+
class AnalysisProfile(val analyzeStdLib: Boolean) {
200200

201201
/**
202202
* Determines whether a given class and method should be transformed (instrumented) for analysis.

common/src/main/org/jetbrains/lincheck/util/Ensure.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,37 +10,37 @@
1010

1111
package org.jetbrains.lincheck.util
1212

13-
internal fun Boolean.ensureTrue(): Boolean {
13+
fun Boolean.ensureTrue(): Boolean {
1414
// TODO: add contracts?
1515
check(this == true)
1616
return this
1717
}
1818

19-
internal fun Boolean.ensureFalse(): Boolean {
19+
fun Boolean.ensureFalse(): Boolean {
2020
// TODO: add contracts?
2121
check(this == false)
2222
return this
2323
}
2424

25-
internal inline fun<T> T.ensure(predicate: (T) -> Boolean): T {
25+
inline fun<T> T.ensure(predicate: (T) -> Boolean): T {
2626
// TODO: add contracts?
2727
check(predicate(this))
2828
return this
2929
}
3030

31-
internal inline fun<T> T.ensure(predicate: (T) -> Boolean, lazyMessage: (T?) -> Any): T {
31+
inline fun<T> T.ensure(predicate: (T) -> Boolean, lazyMessage: (T?) -> Any): T {
3232
// TODO: add contracts?
3333
check(predicate(this)) { lazyMessage(this) }
3434
return this
3535
}
3636

37-
internal fun<T> T?.ensureNull(): T? {
37+
fun<T> T?.ensureNull(): T? {
3838
// TODO: add contracts?
3939
check(this == null)
4040
return this
4141
}
4242

43-
internal fun<T> T?.ensureNull(lazyMessage: (T?) -> Any): T? {
43+
fun<T> T?.ensureNull(lazyMessage: (T?) -> Any): T? {
4444
// TODO: add contracts?
4545
check(this == null) { lazyMessage(this) }
4646
return this

common/src/main/org/jetbrains/lincheck/util/JdkVersion.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ package org.jetbrains.lincheck.util
1414
/**
1515
* Represents a set of Java Development Kit (JDK) major versions since JDK 6.
1616
*/
17-
internal enum class JdkVersion {
17+
enum class JdkVersion {
1818
JDK_6, JDK_7, JDK_8, JDK_9, JDK_10, JDK_11, JDK_12, JDK_13, JDK_14, JDK_15,
1919
JDK_16, JDK_17, JDK_18, JDK_19, JDK_20, JDK_21, JDK_22, JDK_23, JDK_24, JDK_25;
2020
override fun toString(): String {
2121
return "jdk${name.removePrefix("JDK_")}"
2222
}
2323
}
2424

25-
internal val DEFAULT_TEST_JDK_VERSION = JdkVersion.JDK_17
25+
val DEFAULT_TEST_JDK_VERSION = JdkVersion.JDK_17
2626

2727
/**
2828
* Determines the current JDK version based on the `java.specification.version` system property.
2929
* If the system property indicates an unsupported JDK version, an error is thrown.
3030
*/
31-
internal val jdkVersion: JdkVersion = run {
31+
val jdkVersion: JdkVersion = run {
3232
val jdkVersion = System.getProperty("java.specification.version")
3333
// java.specification.version is "1.x" for Java prior to 8 and "x" for the newer ones
3434
when {
@@ -64,4 +64,4 @@ internal val jdkVersion: JdkVersion = run {
6464
/**
6565
* Indicates whether the current Java Development Kit (JDK) version is JDK 8.
6666
*/
67-
internal val isJdk8 = (jdkVersion == JdkVersion.JDK_8)
67+
val isJdk8 = (jdkVersion == JdkVersion.JDK_8)

common/src/main/org/jetbrains/lincheck/util/Logger.kt

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ import java.io.*
1414
import java.time.LocalDateTime
1515
import java.time.format.DateTimeFormatter
1616

17-
internal object Logger {
17+
object Logger {
1818
private val formatter: DateTimeFormatter = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm:ss.SSS")
1919

2020
private val logFile: File? = System.getProperty("lincheck.logFile")?.let { fileName ->
2121
File(fileName).also { runCatching { initFile(it) }.getOrNull() }
2222
}
2323

24-
private val logWriter: Writer = BufferedWriter(
24+
val logWriter: Writer = BufferedWriter(
2525
if (logFile != null) FileWriter(logFile)
2626
else System.err.writer()
2727
)
2828

29-
private val logLevel: LoggingLevel = System.getProperty("lincheck.logLevel")?.uppercase()?.let {
29+
val logLevel: LoggingLevel = System.getProperty("lincheck.logLevel")?.uppercase()?.let {
3030
runCatching { LoggingLevel.valueOf(it) }.getOrElse { DEFAULT_LOG_LEVEL }
3131
} ?: DEFAULT_LOG_LEVEL
3232

@@ -46,13 +46,13 @@ internal object Logger {
4646

4747
fun debug(e: Throwable) = log(LoggingLevel.DEBUG, e)
4848

49-
private inline fun log(logLevel: LoggingLevel, lazyMessage: () -> String) {
49+
inline fun log(logLevel: LoggingLevel, lazyMessage: () -> String) {
5050
if (logLevel >= this.logLevel) {
5151
write(logLevel, lazyMessage(), logWriter)
5252
}
5353
}
5454

55-
private fun write(logLevel: LoggingLevel, s: String, writer: Writer) {
55+
fun write(logLevel: LoggingLevel, s: String, writer: Writer) {
5656
try {
5757
writer.write("[${logLevel.name}] $s$LINE_SEPARATOR")
5858
writer.flush()
@@ -70,10 +70,6 @@ internal object Logger {
7070
}
7171
}
7272

73-
private fun getCurrentTimeStamp(): String {
74-
return formatter.format(LocalDateTime.now())
75-
}
76-
7773
private fun initFile(file: File) {
7874
// create parent directories
7975
file.parentFile?.let { if (!it.exists()) it.mkdirs() }
@@ -86,7 +82,7 @@ internal object Logger {
8682

8783
private val LINE_SEPARATOR = System.lineSeparator()
8884

89-
@JvmField internal val DEFAULT_LOG_LEVEL = LoggingLevel.WARN
85+
@JvmField val DEFAULT_LOG_LEVEL = LoggingLevel.WARN
9086

9187
enum class LoggingLevel {
9288
DEBUG, INFO, WARN, ERROR, OFF

common/src/main/org/jetbrains/lincheck/util/MethodDescriptor.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ package org.jetbrains.lincheck.util
1313
import org.jetbrains.lincheck.descriptors.MethodDescriptor
1414
import org.jetbrains.lincheck.descriptors.Types
1515

16-
internal fun MethodDescriptor.isArraysCopyOfIntrinsic(): Boolean {
16+
fun MethodDescriptor.isArraysCopyOfIntrinsic(): Boolean {
1717
return (
1818
className == "java.util.Arrays" &&
1919
methodName == "copyOf" &&
@@ -26,7 +26,7 @@ internal fun MethodDescriptor.isArraysCopyOfIntrinsic(): Boolean {
2626
)
2727
}
2828

29-
internal fun MethodDescriptor.isArraysCopyOfRangeIntrinsic(): Boolean {
29+
fun MethodDescriptor.isArraysCopyOfRangeIntrinsic(): Boolean {
3030
return (
3131
className == "java.util.Arrays" &&
3232
methodName.contains("copyOfRange") &&
@@ -48,7 +48,7 @@ internal fun MethodDescriptor.isArraysCopyOfRangeIntrinsic(): Boolean {
4848

4949
// TODO: java 8 does not have `@HotSpotIntrinsicCandidate`/`@IntrinsicCandidate` annotations
5050
// add all tracked intrinsics here
51-
internal fun MethodDescriptor.isTrackedIntrinsic(): Boolean =
51+
fun MethodDescriptor.isTrackedIntrinsic(): Boolean =
5252
isArraysCopyOfIntrinsic() ||
5353
isArraysCopyOfRangeIntrinsic()
5454

common/src/main/org/jetbrains/lincheck/util/UnsafeHolder.kt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import java.lang.reflect.Field
1515
import java.lang.reflect.Modifier
1616
import java.util.concurrent.ConcurrentHashMap
1717

18-
internal object UnsafeHolder {
18+
object UnsafeHolder {
1919
val UNSAFE: Unsafe = try {
2020
val unsafeField = Unsafe::class.java.getDeclaredField("theUnsafe")
2121
unsafeField.isAccessible = true
@@ -25,11 +25,11 @@ internal object UnsafeHolder {
2525
}
2626
}
2727

28-
private val fieldOffsetCache = ConcurrentHashMap<Field, Long>()
29-
private val fieldBaseObjectCache = ConcurrentHashMap<Field, Any>()
28+
val fieldOffsetCache = ConcurrentHashMap<Field, Long>()
29+
val fieldBaseObjectCache = ConcurrentHashMap<Field, Any>()
3030

3131
@Suppress("DEPRECATION")
32-
internal inline fun <T> readFieldViaUnsafe(obj: Any?, field: Field, getter: Unsafe.(Any?, Long) -> T): T {
32+
inline fun <T> readFieldViaUnsafe(obj: Any?, field: Field, getter: Unsafe.(Any?, Long) -> T): T {
3333
if (Modifier.isStatic(field.modifiers)) {
3434
val base = fieldBaseObjectCache.computeIfAbsent(field) {
3535
UnsafeHolder.UNSAFE.staticFieldBase(it)
@@ -46,7 +46,7 @@ internal inline fun <T> readFieldViaUnsafe(obj: Any?, field: Field, getter: Unsa
4646
}
4747
}
4848

49-
internal fun readFieldViaUnsafe(obj: Any?, field: Field): Any? {
49+
fun readFieldViaUnsafe(obj: Any?, field: Field): Any? {
5050
if (!field.type.isPrimitive) {
5151
return readFieldViaUnsafe(obj, field, Unsafe::getObject)
5252
}
@@ -67,7 +67,7 @@ internal fun readFieldViaUnsafe(obj: Any?, field: Field): Any? {
6767
* Reads a [field] of the owner object [obj] via Unsafe,
6868
* in case of failure fallbacks into reading the field via reflection.
6969
*/
70-
internal fun readFieldSafely(obj: Any?, field: Field): Result<Any?> =
70+
fun readFieldSafely(obj: Any?, field: Field): Result<Any?> =
7171
// we wrap an unsafe read into `runCatching` to handle `UnsupportedOperationException`,
7272
// which can be thrown, for instance, when attempting to read
7373
// a field of a hidden or record class (starting from Java 15);
@@ -87,7 +87,7 @@ internal fun readFieldSafely(obj: Any?, field: Field): Result<Any?> =
8787
Logger.debug(exception)
8888
}
8989

90-
internal fun readArrayElementViaUnsafe(arr: Any, index: Int): Any? {
90+
fun readArrayElementViaUnsafe(arr: Any, index: Int): Any? {
9191
val offset = getArrayElementOffsetViaUnsafe(arr, index)
9292
val componentType = arr::class.java.componentType
9393

@@ -108,15 +108,15 @@ internal fun readArrayElementViaUnsafe(arr: Any, index: Int): Any? {
108108
}
109109
}
110110

111-
internal fun getArrayElementOffsetViaUnsafe(arr: Any, index: Int): Long {
111+
fun getArrayElementOffsetViaUnsafe(arr: Any, index: Int): Long {
112112
val clazz = arr::class.java
113113
val baseOffset = UnsafeHolder.UNSAFE.arrayBaseOffset(clazz).toLong()
114114
val indexScale = UnsafeHolder.UNSAFE.arrayIndexScale(clazz).toLong()
115115
return baseOffset + index * indexScale
116116
}
117117

118118
@Suppress("DEPRECATION")
119-
internal inline fun writeFieldViaUnsafe(obj: Any?, field: Field, value: Any?, setter: Unsafe.(Any?, Long, Any?) -> Unit) {
119+
inline fun writeFieldViaUnsafe(obj: Any?, field: Field, value: Any?, setter: Unsafe.(Any?, Long, Any?) -> Unit) {
120120
if (Modifier.isStatic(field.modifiers)) {
121121
val base = UnsafeHolder.UNSAFE.staticFieldBase(field)
122122
val offset = UnsafeHolder.UNSAFE.staticFieldOffset(field)
@@ -128,7 +128,7 @@ internal inline fun writeFieldViaUnsafe(obj: Any?, field: Field, value: Any?, se
128128
}
129129

130130
@Suppress("NAME_SHADOWING")
131-
internal fun writeFieldViaUnsafe(obj: Any?, field: Field, value: Any?) {
131+
fun writeFieldViaUnsafe(obj: Any?, field: Field, value: Any?) {
132132
if (!field.type.isPrimitive) {
133133
return writeFieldViaUnsafe(obj, field, value, Unsafe::putObject)
134134
}
@@ -145,7 +145,7 @@ internal fun writeFieldViaUnsafe(obj: Any?, field: Field, value: Any?) {
145145
}
146146
}
147147

148-
internal fun writeArrayElementViaUnsafe(arr: Any, index: Int, value: Any?): Any? {
148+
fun writeArrayElementViaUnsafe(arr: Any, index: Int, value: Any?): Any? {
149149
val offset = getArrayElementOffsetViaUnsafe(arr, index)
150150
val componentType = arr::class.java.componentType
151151

@@ -167,7 +167,7 @@ internal fun writeArrayElementViaUnsafe(arr: Any, index: Int, value: Any?): Any?
167167
}
168168

169169
@Suppress("DEPRECATION")
170-
internal fun getFieldOffsetViaUnsafe(field: Field): Long {
170+
fun getFieldOffsetViaUnsafe(field: Field): Long {
171171
return if (Modifier.isStatic(field.modifiers)) {
172172
UnsafeHolder.UNSAFE.staticFieldOffset(field)
173173
}
@@ -180,7 +180,7 @@ private val fieldNameByOffsetCache = ConcurrentHashMap<Pair<Class<*>, Long>, Str
180180
private val NULL_FIELD_NAME = ".+- NULL -+." // cannot store `null` in the cache.
181181

182182
@Suppress("DEPRECATION")
183-
internal fun findFieldNameByOffsetViaUnsafe(targetType: Class<*>, offset: Long): String? =
183+
fun findFieldNameByOffsetViaUnsafe(targetType: Class<*>, offset: Long): String? =
184184
fieldNameByOffsetCache.getOrPut(targetType to offset) {
185185
findFieldNameByOffsetViaUnsafeImpl(targetType, offset) ?: NULL_FIELD_NAME
186186
}.let { if (it == NULL_FIELD_NAME) null else it }

0 commit comments

Comments
 (0)