• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

oracle / opengrok / #3721

30 Nov 2023 04:03PM UTC coverage: 66.155% (-9.8%) from 75.915%
#3721

push

vladak
1.12.25

38762 of 58593 relevant lines covered (66.15%)

0.66 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.57
/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/executables/JavaClassAnalyzer.java
1
/*
2
 * CDDL HEADER START
3
 *
4
 * The contents of this file are subject to the terms of the
5
 * Common Development and Distribution License (the "License").
6
 * You may not use this file except in compliance with the License.
7
 *
8
 * See LICENSE.txt included in this distribution for the specific
9
 * language governing permissions and limitations under the License.
10
 *
11
 * When distributing Covered Code, include this CDDL HEADER in each
12
 * file and include the License file at LICENSE.txt.
13
 * If applicable, add the following below this CDDL HEADER, with the
14
 * fields enclosed by brackets "[]" replaced with your own identifying
15
 * information: Portions Copyright [yyyy] [name of copyright owner]
16
 *
17
 * CDDL HEADER END
18
 */
19

20
/*
21
 * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
22
 * Portions Copyright (c) 2018, 2020, Chris Fraire <cfraire@me.com>.
23
 * Portions Copyright (c) 2020, Lubos Kosco <tarzanek@gmail.com>.
24
 */
25
package org.opengrok.indexer.analysis.executables;
26

27
import java.io.IOException;
28
import java.io.InputStream;
29
import java.io.StringWriter;
30
import java.io.Writer;
31
import java.util.ArrayList;
32
import java.util.List;
33
import java.util.logging.Level;
34
import java.util.logging.Logger;
35
import org.apache.bcel.classfile.Attribute;
36
import org.apache.bcel.classfile.ClassFormatException;
37
import org.apache.bcel.classfile.ClassParser;
38
import org.apache.bcel.classfile.Code;
39
import org.apache.bcel.classfile.Constant;
40
import org.apache.bcel.classfile.ConstantCP;
41
import org.apache.bcel.classfile.ConstantClass;
42
import org.apache.bcel.classfile.ConstantDouble;
43
import org.apache.bcel.classfile.ConstantFloat;
44
import org.apache.bcel.classfile.ConstantInteger;
45
import org.apache.bcel.classfile.ConstantLong;
46
import org.apache.bcel.classfile.ConstantMethodType;
47
import org.apache.bcel.classfile.ConstantModule;
48
import org.apache.bcel.classfile.ConstantNameAndType;
49
import org.apache.bcel.classfile.ConstantPackage;
50
import org.apache.bcel.classfile.ConstantPool;
51
import org.apache.bcel.classfile.ConstantString;
52
import org.apache.bcel.classfile.ConstantUtf8;
53
import org.apache.bcel.classfile.ExceptionTable;
54
import org.apache.bcel.classfile.JavaClass;
55
import org.apache.bcel.classfile.LocalVariable;
56
import org.apache.bcel.classfile.LocalVariableTable;
57
import org.apache.bcel.classfile.Utility;
58
import org.apache.lucene.document.Document;
59
import org.apache.lucene.document.Field.Store;
60
import org.opengrok.indexer.analysis.AnalyzerFactory;
61
import org.opengrok.indexer.analysis.FileAnalyzer;
62
import org.opengrok.indexer.analysis.OGKTextField;
63
import org.opengrok.indexer.analysis.OGKTextVecField;
64
import org.opengrok.indexer.analysis.StreamSource;
65
import org.opengrok.indexer.configuration.RuntimeEnvironment;
66
import org.opengrok.indexer.logger.LoggerFactory;
67
import org.opengrok.indexer.search.QueryBuilder;
68
import org.opengrok.indexer.web.QueryParameters;
69
import org.opengrok.indexer.web.Util;
70

71
/**
72
 * Analyzes Java Class files.
73
 *
74
 * Created on September 23, 2005
75
 * @author Chandan
76
 * @author Lubos Kosco , January 2010 , updated bcel, comment on thread safety
77
 */
78
public class JavaClassAnalyzer extends FileAnalyzer {
79

80
    private static final Logger LOGGER = LoggerFactory.getLogger(JavaClassAnalyzer.class);
1✔
81

82
    private final String urlPrefix = RuntimeEnvironment.getInstance().getUrlPrefix();
1✔
83

84
    /**
85
     * Creates a new instance of JavaClassAnalyzer.
86
     *
87
     * @param factory The factory that creates JavaClassAnalyzers
88
     */
89
    protected JavaClassAnalyzer(AnalyzerFactory factory) {
90
        super(factory);
1✔
91
    }
1✔
92

93
    /**
94
     * @return {@code null} as there is no aligned language
95
     */
96
    @Override
97
    public String getCtagsLang() {
98
        return null;
1✔
99
    }
100

101
    /**
102
     * Gets a version number to be used to tag processed documents so that
103
     * re-analysis can be re-done later if a stored version number is different
104
     * from the current implementation.
105
     * @return 20180612_00
106
     */
107
    @Override
108
    protected int getSpecializedVersionNo() {
109
        return 20180612_00; // Edit comment above too!
1✔
110
    }
111

112
    @Override
113
    public void analyze(Document doc, StreamSource src, Writer xrefOut) throws IOException {
114
        try (InputStream in = src.getStream()) {
1✔
115
            analyze(doc, in, xrefOut, null);
1✔
116
        }
117
    }
1✔
118

119
    void analyze(Document doc, InputStream in, Writer xrefOut,
120
            JFieldBuilder jfbuilder) throws IOException {
121
        List<String> defs = new ArrayList<>();
1✔
122
        List<String> refs = new ArrayList<>();
1✔
123
        List<String> full = new ArrayList<>();
1✔
124

125
        StringWriter dout, rout, fout;
126
        if (jfbuilder == null) {
1✔
127
            dout = new StringWriter();
1✔
128
            rout = new StringWriter();
1✔
129
            fout = new StringWriter();
1✔
130
        } else {
131
            dout = jfbuilder.write(QueryBuilder.DEFS);
1✔
132
            rout = jfbuilder.write(QueryBuilder.REFS);
1✔
133
            fout = jfbuilder.write(QueryBuilder.FULL);
1✔
134
        }
135

136
        ClassParser classparser = new ClassParser(in,
1✔
137
            doc.get(QueryBuilder.PATH));
1✔
138
        StringWriter xout = new StringWriter();
1✔
139
        getContent(xout, fout, classparser.parse(), defs, refs, full);
1✔
140
        String xref = xout.toString();
1✔
141

142
        if (xrefOut != null) {
1✔
143
            xrefOut.append(xref);
1✔
144
            try {
145
                xrefOut.flush();
1✔
146
            } catch (IOException ex) {
×
147
                LOGGER.log(Level.WARNING, "Couldn''t flush. Will retry once added to doc", ex);
×
148
            }
1✔
149
        }
150

151
        appendValues(dout, defs);
1✔
152
        appendValues(rout, refs);
1✔
153
        appendValues(fout, full);
1✔
154

155
        if (jfbuilder == null) {
1✔
156
            String dstr = dout.toString();
1✔
157
            doc.add(new OGKTextVecField(QueryBuilder.DEFS, dstr, Store.NO));
1✔
158

159
            String rstr = rout.toString();
1✔
160
            doc.add(new OGKTextField(QueryBuilder.REFS, rstr, Store.NO));
1✔
161

162
            String fstr = fout.toString();
1✔
163
            doc.add(new OGKTextField(QueryBuilder.FULL, fstr, Store.NO));
1✔
164
        }
165
    }
1✔
166

167

168
    private static final String AHREF = "<a href=\"";
169
    private static final String AHREFT_END = "\">";
170
    private static final String AHREFEND = "</a>";
171
    private static final String AIHREF = "\" href=\"";
172
    private static final String ADHREF = "<a class=\"d\" name=\"";
173
    private final StringBuffer rstring = new StringBuffer(512);
1✔
174
    protected String linkPath(String path) {
175
        rstring.setLength(0);
1✔
176
        return rstring.append(AHREF).append(urlPrefix).append(QueryParameters.PATH_SEARCH_PARAM_EQ)
1✔
177
                .append(Util.uriEncodePath(path)).append(AHREFT_END)
1✔
178
                .append(Util.htmlize(path)).append(AHREFEND).toString();
1✔
179
    }
180

181
    protected String linkDef(String def) {
182
        rstring.setLength(0);
1✔
183
        return rstring.append(AHREF).append(urlPrefix).append(QueryParameters.DEFS_SEARCH_PARAM_EQ)
1✔
184
                .append(Util.uriEncode(def)).append(AHREFT_END)
1✔
185
                .append(Util.htmlize(def)).append(AHREFEND).toString();
1✔
186
    }
187

188
    protected String tagDef(String def) {
189
        // The fragment identifiers in HTML 4 must start with a letter, so
190
        // <init> (for constructors) or <clinit> (for class initializers)
191
        // cannot be used as identifiers. Also the $ character in inner
192
        // classes is not allowed. Strip away such characters for now.
193
        // HTML 5 does not have these restrictions.
194
        String name = def.replaceAll("[<>$]", "");
1✔
195

196
        rstring.setLength(0);
1✔
197
        return rstring.append(ADHREF).append(Util.formQuoteEscape(name))
1✔
198
                .append(AIHREF).append(urlPrefix).append(QueryParameters.DEFS_SEARCH_PARAM_EQ)
1✔
199
                .append(Util.uriEncode(def)).append(AHREFT_END)
1✔
200
                .append(Util.htmlize(def)).append(AHREFEND).toString();
1✔
201
    }
202

203
private static final String PACKAGE = "package ";
204
private static final char EOL = '\n';
205
private static final char TAB = '\t';
206
private static final char SPACE = ' ';
207
private static final String EXTENDS = " extends ";
208
private static final String IMPLEMENTS = " implements ";
209
private static final String THROWS = " throws ";
210
private static final String THIS = "this";
211
private static final String LCBREOL = " {\n";
212
private static final String LBRA = " (";
213
private static final String COMMA = ", ";
214
private static final String RBRA = ") ";
215
private static final String RCBREOL = "}\n";
216

217
//TODO this class needs to be thread safe to avoid bug 13364, which was fixed by just updating bcel to 5.2
218
    private void getContent(Writer out, Writer fout, JavaClass c,
219
            List<String> defs, List<String> refs, List<String> full)
220
            throws IOException {
221
        String t;
222
        ConstantPool cp = c.getConstantPool();
1✔
223

224

225
        int[] v = new int[cp.getLength() + 1];
1✔
226
        out.write(linkPath(t = c.getSourceFileName()));
1✔
227
        defs.add(t);
1✔
228
        refs.add(t);
1✔
229
        fout.write(t);
1✔
230
        out.write(EOL);
1✔
231
        fout.write(EOL);
1✔
232

233
        out.write(PACKAGE);
1✔
234
        fout.write(PACKAGE);
1✔
235
        out.write(linkDef(t = c.getPackageName()));
1✔
236
        defs.add(t);
1✔
237
        refs.add(t);
1✔
238
        fout.write(t);
1✔
239

240
        out.write(EOL);
1✔
241
        fout.write(EOL);
1✔
242
        String aflg;
243
        out.write(aflg = Utility.accessToString(c.getAccessFlags(), true));
1✔
244
        if (aflg != null) {
1✔
245
            out.write(SPACE);
1✔
246
            fout.write(aflg);
1✔
247
            fout.write(SPACE);
1✔
248
        }
249

250
        v[c.getClassNameIndex()] = 1;
1✔
251
        out.write(tagDef(t = c.getClassName()));
1✔
252
        defs.add(t);
1✔
253
        refs.add(t);
1✔
254
        fout.write(t);
1✔
255
        out.write(EXTENDS);
1✔
256
        fout.write(EXTENDS);
1✔
257

258
        v[c.getSuperclassNameIndex()] = 1;
1✔
259
        out.write(linkDef(t = c.getSuperclassName()));
1✔
260
        refs.add(t);
1✔
261
        fout.write(t);
1✔
262
        for (int i : c.getInterfaceIndices()) {
1✔
263
            v[i] = 1;
1✔
264
        }
265
        String[] ins = c.getInterfaceNames();
1✔
266
        if (ins != null && ins.length > 0) {
1✔
267
            out.write(IMPLEMENTS);
1✔
268
            fout.write(IMPLEMENTS);
1✔
269
            for (String in : ins) {
1✔
270
                out.write(linkDef(t = in));
1✔
271
                refs.add(t);
1✔
272
                fout.write(t);
1✔
273
                out.write(SPACE);
1✔
274
                fout.write(SPACE);
1✔
275
            }
276
        }
277
        out.write(LCBREOL);
1✔
278
        fout.write(LCBREOL);
1✔
279

280
        for (Attribute a : c.getAttributes()) {
1✔
281
            if (a.getTag() == org.apache.bcel.Const.ATTR_CODE) {
1✔
282
                for (Attribute ca : ((Code) a).getAttributes()) {
×
283
                    if (ca.getTag() == org.apache.bcel.Const.ATTR_LOCAL_VARIABLE_TABLE) {
×
284
                        for (LocalVariable l : ((LocalVariableTable) ca).getLocalVariableTable()) {
×
285
                            printLocal(out, fout, l, v, defs, refs);
×
286
                        }
287
                    }
288
                }
289
            } else if (a.getTag() == org.apache.bcel.Const.ATTR_BOOTSTRAP_METHODS ) {
1✔
290
                // TODO fill in bootstrap methods, fix the else if
291
            } else if (a.getTag() == org.apache.bcel.Const.ATTR_SOURCE_FILE) {
1✔
292
                v[a.getNameIndex()] = 1;
1✔
293
                break;
1✔
294
            }
295
        }
296

297
        String aflgs;
298
        String fldsig;
299
        String tdef;
300
        for (org.apache.bcel.classfile.Field fld : c.getFields()) {
1✔
301
            out.write(TAB);
1✔
302
            fout.write(TAB);
1✔
303
            aflgs = Utility.accessToString(fld.getAccessFlags());
1✔
304
            if (aflgs != null && aflgs.length() > 0) {
1✔
305
                out.write(aflgs);
1✔
306
                fout.write(aflgs);
1✔
307
                fout.write(SPACE);
1✔
308
                out.write(SPACE);
1✔
309
            }
310
            fldsig = Utility.typeSignatureToString(fld.getSignature(), true);
1✔
311
            out.write(fldsig);
1✔
312
            fout.write(fldsig);
1✔
313
            out.write(SPACE);
1✔
314
            fout.write(SPACE);
1✔
315
            tdef = tagDef(t = fld.getName());
1✔
316
            out.write(tdef);
1✔
317
            fout.write(tdef);
1✔
318
            defs.add(t);
1✔
319
            refs.add(t);
1✔
320
            out.write(EOL);
1✔
321
            fout.write(EOL);
1✔
322
            //TODO show Attributes
323
        }
324

325
        String sig;
326
        String msig;
327
        String ltdef;
328
        for (org.apache.bcel.classfile.Method m : c.getMethods()) {
1✔
329
            out.write(TAB);
1✔
330
            fout.write(TAB);
1✔
331
            aflgs = Utility.accessToString(m.getAccessFlags());
1✔
332
            if (aflgs != null && aflgs.length() > 0) {
1✔
333
                out.write(aflgs);
1✔
334
                fout.write(aflgs);
1✔
335
                out.write(SPACE);
1✔
336
                fout.write(SPACE);
1✔
337
            }
338
            sig = m.getSignature();
1✔
339
            msig = Utility.methodSignatureReturnType(sig, false);
1✔
340
            out.write(msig);
1✔
341
            fout.write(msig);
1✔
342
            out.write(SPACE);
1✔
343
            fout.write(SPACE);
1✔
344
            ltdef = tagDef(t = m.getName());
1✔
345
            out.write(ltdef);
1✔
346
            fout.write(ltdef);
1✔
347
            defs.add(t);
1✔
348
            refs.add(t);
1✔
349
            out.write(LBRA);
1✔
350
            fout.write(LBRA);
1✔
351
            String[] args = Utility.methodSignatureArgumentTypes(sig, false);
1✔
352
            for (int i = 0; i < args.length; i++) {
1✔
353
                t = args[i];
1✔
354
                out.write(t);
1✔
355
                fout.write(t);
1✔
356
                int spi = t.indexOf(SPACE);
1✔
357
                if (spi > 0) {
1✔
358
                    refs.add(t.substring(0, spi));
×
359
                    defs.add(t.substring(spi + 1));
×
360
                }
361
                if (i < args.length - 1) {
1✔
362
                    out.write(COMMA);
1✔
363
                    fout.write(COMMA);
1✔
364
                }
365
            }
366
            out.write(RBRA);
1✔
367
            fout.write(RBRA);
1✔
368
            ArrayList<LocalVariable[]> locals = new ArrayList<>();
1✔
369
            for (Attribute a : m.getAttributes()) {
1✔
370
                if (a.getTag() == org.apache.bcel.Const.ATTR_EXCEPTIONS) {
1✔
371
                    for (int i : ((ExceptionTable) a).getExceptionIndexTable()) {
×
372
                        v[i] = 1;
×
373
                    }
374
                    String[] exs = ((ExceptionTable) a).getExceptionNames();
×
375
                    if (exs != null && exs.length > 0) {
×
376
                        out.write(THROWS);
×
377
                        fout.write(THROWS);
×
378
                        for (String ex : exs) {
×
379
                            out.write(linkDef(ex));
×
380
                            fout.write(ex);
×
381
                            refs.add(ex);
×
382
                            out.write(SPACE);
×
383
                            fout.write(SPACE);
×
384
                        }
385
                    }
386
                } else if (a.getTag() == org.apache.bcel.Const.ATTR_CODE) {
1✔
387
                    for (Attribute ca : ((Code) a).getAttributes()) {
1✔
388
                        if (ca.getTag() == org.apache.bcel.Const.ATTR_LOCAL_VARIABLE_TABLE) {
1✔
389
                            locals.add(((LocalVariableTable) ca).getLocalVariableTable());
1✔
390
                        }
391
                    }
392
                }
393
            }
394
            out.write(EOL);
1✔
395
            fout.write(EOL);
1✔
396
            if (!locals.isEmpty()) {
1✔
397
                for (LocalVariable[] ls : locals) {
1✔
398
                    for (LocalVariable l : ls) {
1✔
399
                        printLocal(out, fout, l, v, defs, refs);
1✔
400
                    }
401
                }
1✔
402
            }
403
        }
404
        out.write(RCBREOL);
1✔
405
        fout.write(RCBREOL);
1✔
406
        for (int i = 0; i < v.length - 1; i++) {
1✔
407
            if (v[i] != 1) {
1✔
408
                Constant constant = cp.getConstant(i);
1✔
409
                if (constant != null) {
1✔
410
                    full.add(constantToString(constant, cp, v));
1✔
411
                }
412
            }
413
        }
414
    }
1✔
415

416
    private void printLocal(Writer out, Writer fout, LocalVariable l,
417
            int[] v, List<String> defs, List<String> refs) throws IOException {
418
        v[l.getIndex()] = 1;
1✔
419
        v[l.getNameIndex()] = 1;
1✔
420
        v[l.getSignatureIndex()] = 1;
1✔
421
        if (!THIS.equals(l.getName())) {
1✔
422
            out.write(TAB);
1✔
423
            out.write(TAB);
1✔
424
            fout.write(TAB);
1✔
425
            fout.write(TAB);
1✔
426
            String sig = Utility.typeSignatureToString(l.getSignature(), true);
1✔
427
            out.write(sig);
1✔
428
            fout.write(sig);
1✔
429
            out.write(SPACE);
1✔
430
            fout.write(SPACE);
1✔
431
            String t;
432
            out.write(t = l.getName());
1✔
433
            defs.add(t);
1✔
434
            refs.add(t);
1✔
435
            fout.write(t);
1✔
436
            out.write(EOL);
1✔
437
            fout.write(EOL);
1✔
438
        }
439
    }
1✔
440

441
    public String constantToString(Constant c, ConstantPool cp, int[] v)
442
            throws ClassFormatException {
443
        String str;
444
        int i, j, k;
445
        byte tag = c.getTag();
1✔
446

447
        switch (tag) {
1✔
448
            case org.apache.bcel.Const.CONSTANT_Class:
449
                i = ((ConstantClass) c).getNameIndex();
1✔
450
                v[i] = 1;
1✔
451
                Constant con = cp.getConstant(i, org.apache.bcel.Const.CONSTANT_Utf8);
1✔
452
                str = Utility.compactClassName(((ConstantUtf8) con).getBytes(), false);
1✔
453
                break;
1✔
454

455
            case org.apache.bcel.Const.CONSTANT_String:
456
                i = ((ConstantString) c).getStringIndex();
1✔
457
                v[i] = 1;
1✔
458
                Constant con2 = cp.getConstant(i, org.apache.bcel.Const.CONSTANT_Utf8);
1✔
459
                str = ((ConstantUtf8) con2).getBytes();
1✔
460
                break;
1✔
461

462
            case org.apache.bcel.Const.CONSTANT_Utf8:
463
                str = ((ConstantUtf8) c).toString();
1✔
464
                break;
1✔
465
            case org.apache.bcel.Const.CONSTANT_Double:
466
                str = ((ConstantDouble) c).toString();
×
467
                break;
×
468
            case org.apache.bcel.Const.CONSTANT_Float:
469
                str = ((ConstantFloat) c).toString();
×
470
                break;
×
471
            case org.apache.bcel.Const.CONSTANT_Long:
472
                str = ((ConstantLong) c).toString();
×
473
                break;
×
474
            case org.apache.bcel.Const.CONSTANT_Integer:
475
                str = ((ConstantInteger) c).toString();
×
476
                break;
×
477

478
            case org.apache.bcel.Const.CONSTANT_NameAndType:
479
                i = ((ConstantNameAndType) c).getNameIndex();
1✔
480
                v[i] = 1;
1✔
481
                j = ((ConstantNameAndType) c).getSignatureIndex();
1✔
482
                v[j] = 1;
1✔
483
                String sig = constantToString(cp.getConstant(j), cp, v);
1✔
484
                if (sig.charAt(0) == '(') {
1✔
485
                    str = Utility.methodSignatureToString(sig,
×
486
                            constantToString(cp.getConstant(i), cp, v), " ");
×
487
                } else {
488
                    str = Utility.typeSignatureToString(sig, true) + ' ' +
1✔
489
                            constantToString(cp.getConstant(i), cp, v);
1✔
490
                }
491
                //str = constantToString(cp.getConstant(i)) +' ' + sig;
492

493
                break;
1✔
494

495
            case org.apache.bcel.Const.CONSTANT_InterfaceMethodref:
496
            case org.apache.bcel.Const.CONSTANT_Methodref:
497
            case org.apache.bcel.Const.CONSTANT_Fieldref:
498
                i = ((ConstantCP) c).getClassIndex();
1✔
499
                v[i] = 1;
1✔
500
                j = ((ConstantCP) c).getNameAndTypeIndex();
1✔
501
                v[j] = 1;
1✔
502
                str = (constantToString(cp.getConstant(i), cp, v) + ' ' +
1✔
503
                        constantToString(cp.getConstant(j), cp, v));
1✔
504
                break;
1✔
505

506
            case org.apache.bcel.Const.CONSTANT_MethodType:
507
                i = ((ConstantMethodType) c).getDescriptorIndex();
×
508
                v[i] = 1;
×
509
                str = constantToString(cp.getConstant(i), cp, v);
×
510
                break;
×
511
//                CONSTANT_MethodType_info {
512
//    u1 tag;
513
//    u2 descriptor_index;
514
//}
515
            case org.apache.bcel.Const.CONSTANT_MethodHandle:
516
    //TODO fix implementation as per below to have proper lookup table/constants
517
//                i = ((ConstantMethodHandle) c).getReferenceKind();
518
//                v[i] = 1;
519
//                j = ((ConstantMethodHandle) c).getReferenceIndex();
520
//                v[j] = 1;
521
//                str = (constantToString(cp.getConstant(i), cp, v) + ' ' +
522
//                        constantToString(cp.getConstant(j), cp, v));
523
                str = "";
×
524
                break;
×
525
//                CONSTANT_MethodHandle_info {
526
//    u1 tag;
527
//    u1 reference_kind;
528
//    u2 reference_index;
529
//}
530
            case org.apache.bcel.Const.CONSTANT_InvokeDynamic:
531
    //TODO fix implementation as per below and add bootstrap method tables first
532
//                i = ((ConstantInvokeDynamic) c).getClassIndex();
533
//                v[i] = 1;
534
//                j = ((ConstantInvokeDynamic) c).getNameAndTypeIndex();
535
//                v[j] = 1;
536
//                k = ((ConstantInvokeDynamic) c).getBootstrapMethodAttrIndex();
537
//                v[k] = 1;
538
//                str = (constantToString(cp.getConstant(i), cp, v) + ' ' +
539
//                        constantToString(cp.getConstant(j), cp, v) + ' ' +
540
//                        constantToString(cp.getConstant(k), cp, v));
541
                str = "";
×
542
                break;
×
543
            case org.apache.bcel.Const.CONSTANT_Package:
544
                i = ((ConstantPackage) c).getNameIndex();
×
545
                v[i] = 1;
×
546
                str = constantToString(cp.getConstant(i), cp, v);
×
547
                break;
×
548
            case org.apache.bcel.Const.CONSTANT_Module:
549
                i = ((ConstantModule) c).getNameIndex();
×
550
                v[i] = 1;
×
551
                str = constantToString(cp.getConstant(i), cp, v);
×
552
                break;
×
553

554
//                CONSTANT_InvokeDynamic_info {
555
//    u1 tag;
556
//    u2 bootstrap_method_attr_index;
557
//    u2 name_and_type_index;
558
//}
559

560
// if types are missing add more as per
561
// https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.4.2
562
// and bcel docs
563
// https://commons.apache.org/proper/commons-bcel/apidocs/org/apache/bcel/classfile/Constant.html
564

565
            default: // Never reached
566
                throw new ClassFormatException("Unknown constant type " + tag);
×
567
        }
568
        return str;
1✔
569
    }
570

571
    private static void appendValues(StringWriter accum, List<String> full) {
572
        for (String fl : full) {
1✔
573
            accum.write(fl);
1✔
574
            accum.write(EOL);
1✔
575
        }
1✔
576
    }
1✔
577
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc