Debian Codegraph @

bind/testdata/testpkg/javapkg/classes.go

raw symbols SCIP
1 // Copyright 2016 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package javapkg
6
7 import (
8 "Java/java/beans"
9 "Java/java/io"
10 "Java/java/io/IOException"
11 "Java/java/lang"
12 "Java/java/lang/Character"
13 "Java/java/lang/Integer"
14 "Java/java/lang/Object"
15 "Java/java/lang/Runnable"
16 "Java/java/net"
17 "Java/java/nio"
18 "Java/java/util"
19 "Java/java/util/concurrent"
20 gopkg "Java/javapkg"
21 xnet "Java/javax/net"
22 )
23
24 const (
25 ToStringPrefix = "Go toString: "
26 IOExceptionMessage = "GoInputStream IOException"
27 )
28
29 type GoRunnable struct {
30 lang.Object
31 lang.Runnable
32 this lang.Runnable
33
34 Field string
35 }
36
37 func (r *GoRunnable) ToString(this gopkg.GoRunnable) string {
38 return ToStringPrefix
39 }
40
41 func (r *GoRunnable) Run(this gopkg.GoRunnable) {
42 }
43
44 func (r *GoRunnable) GetThis(this gopkg.GoRunnable) lang.Runnable {
45 return this
46 }
47
48 type GoInputStream struct {
49 io.InputStream
50 }
51
52 func (_ *GoInputStream) Read() (int32, error) {
53 return 0, IOException.New(IOExceptionMessage)
54 }
55
56 func NewGoInputStream() *GoInputStream {
57 return new(GoInputStream)
58 }
59
60 type GoFuture struct {
61 concurrent.Future
62 }
63
64 func (_ *GoFuture) Cancel(_ bool) bool {
65 return false
66 }
67
68 func (_ *GoFuture) Get() (lang.Object, error) {
69 return nil, nil
70 }
71
72 // Use a trailing underscore to override multiple overloaded methods.
73 func (_ *GoFuture) Get_(_ int64, _ concurrent.TimeUnit) (lang.Object, error) {
74 return nil, nil
75 }
76
77 func (_ *GoFuture) IsCancelled() bool {
78 return false
79 }
80
81 func (_ *GoFuture) IsDone() bool {
82 return false
83 }
84
85 type GoObject struct {
86 lang.Object
87 this lang.Object
88 }
89
90 func (o *GoObject) ToString(this gopkg.GoObject) string {
91 o.this = this
92 return ToStringPrefix + this.Super().ToString()
93 }
94
95 func (_ *GoObject) HashCode() int32 {
96 return 42
97 }
98
99 func RunRunnable(r lang.Runnable) {
100 r.Run()
101 }
102
103 func RunnableRoundtrip(r lang.Runnable) lang.Runnable {
104 return r
105 }
106
107 // Test constructing and returning Go instances of GoObject and GoRunnable
108 // outside a constructor
109 func ConstructGoRunnable() *GoRunnable {
110 return new(GoRunnable)
111 }
112
113 func ConstructGoObject() *GoObject {
114 return new(GoObject)
115 }
116
117 // java.beans.PropertyChangeEvent is a class a with no default constructors.
118 type GoPCE struct {
119 beans.PropertyChangeEvent
120 }
121
122 func NewGoPCE(_ lang.Object, _ string, _ lang.Object, _ lang.Object) *GoPCE {
123 return new(GoPCE)
124 }
125
126 // java.util.ArrayList is a class with multiple constructors
127 type GoArrayList struct {
128 util.ArrayList
129 }
130
131 func NewGoArrayList() *GoArrayList {
132 return new(GoArrayList)
133 }
134
135 func NewGoArrayListWithCap(_ int32) *GoArrayList {
136 return new(GoArrayList)
137 }
138
139 func UnwrapGoArrayList(l gopkg.GoArrayList) {
140 _ = l.Unwrap().(*GoArrayList)
141 }
142
143 func CallSubset(s Character.Subset) {
144 s.ToString()
145 }
146
147 type GoSubset struct {
148 Character.Subset
149 }
150
151 func NewGoSubset(_ string) *GoSubset {
152 return new(GoSubset)
153 }
154
155 func NewJavaObject() lang.Object {
156 return Object.New()
157 }
158
159 func NewJavaInteger() lang.Integer {
160 i, _ := Integer.New(int32(42))
161 return i
162 }
163
164 type NoargConstructor struct {
165 util.BitSet // An otherwise unused class with a no-arg constructor
166 }
167
168 type GoRand struct {
169 util.Random
170 }
171
172 func (_ *GoRand) Next(this gopkg.GoRand, i int32) int32 {
173 return this.Super().Next(i)
174 }
175
176 type I interface{}
177
178 func CastInterface(intf I) lang.Runnable {
179 var r lang.Runnable = Runnable.Cast(intf)
180 r.Run()
181 return r
182 }
183
184 func CastRunnable(o lang.Object) lang.Runnable {
185 defer func() {
186 recover() // swallow the panic
187 }()
188 var r lang.Runnable = Runnable.Cast(o)
189 r.Run()
190 return r
191 }
192
193 // Test that extending classes from Java packages
194 // with the same last component (in this case "net")
195 // works.
196 func NameClashingPackages(_ net.Socket, _ xnet.SocketFactory) {
197 }
198
199 func testReferenceToUnsupportedParameters() {
200 var ib nio.IntBuffer
201 ib.Put(nil)
202 }