< prev index next >

src/java.base/share/classes/jdk/internal/classfile/impl/ClassRemapperImpl.java

Print this page

  1 /*
  2  * Copyright (c) 2023, 2025, 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

 67                         .map(this::mapRecordComponent).toList()));
 68             case ModuleAttribute ma ->
 69                 clb.with(ModuleAttribute.of(ma.moduleName(), ma.moduleFlagsMask(),
 70                         ma.moduleVersion().orElse(null),
 71                         ma.requires(), ma.exports(), ma.opens(),
 72                         ma.uses().stream().map(ce ->
 73                                 clb.constantPool().classEntry(map(ce.asSymbol()))).toList(),
 74                         ma.provides().stream().map(mp ->
 75                                 ModuleProvideInfo.of(map(mp.provides().asSymbol()),
 76                                         mp.providesWith().stream().map(pw ->
 77                                                 map(pw.asSymbol())).toList())).toList()));
 78             case NestHostAttribute nha ->
 79                 clb.with(NestHostAttribute.of(map(nha.nestHost().asSymbol())));
 80             case NestMembersAttribute nma ->
 81                 clb.with(NestMembersAttribute.ofSymbols(nma.nestMembers().stream()
 82                         .map(nm -> map(nm.asSymbol())).toList()));
 83             case PermittedSubclassesAttribute psa ->
 84                 clb.with(PermittedSubclassesAttribute.ofSymbols(
 85                         psa.permittedSubclasses().stream().map(ps ->
 86                                 map(ps.asSymbol())).toList()));




 87             case RuntimeVisibleAnnotationsAttribute aa ->
 88                 clb.with(RuntimeVisibleAnnotationsAttribute.of(
 89                         mapAnnotations(aa.annotations())));
 90             case RuntimeInvisibleAnnotationsAttribute aa ->
 91                 clb.with(RuntimeInvisibleAnnotationsAttribute.of(
 92                         mapAnnotations(aa.annotations())));
 93             case RuntimeVisibleTypeAnnotationsAttribute aa ->
 94                 clb.with(RuntimeVisibleTypeAnnotationsAttribute.of(
 95                         mapTypeAnnotations(aa.annotations())));
 96             case RuntimeInvisibleTypeAnnotationsAttribute aa ->
 97                 clb.with(RuntimeInvisibleTypeAnnotationsAttribute.of(
 98                         mapTypeAnnotations(aa.annotations())));
 99             default ->
100                 clb.with(cle);
101         }
102     }
103 
104     @Override
105     public FieldTransform asFieldTransform() {
106         return (FieldBuilder fb, FieldElement fe) -> {

  1 /*
  2  * Copyright (c) 2023, 2026, 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

 67                         .map(this::mapRecordComponent).toList()));
 68             case ModuleAttribute ma ->
 69                 clb.with(ModuleAttribute.of(ma.moduleName(), ma.moduleFlagsMask(),
 70                         ma.moduleVersion().orElse(null),
 71                         ma.requires(), ma.exports(), ma.opens(),
 72                         ma.uses().stream().map(ce ->
 73                                 clb.constantPool().classEntry(map(ce.asSymbol()))).toList(),
 74                         ma.provides().stream().map(mp ->
 75                                 ModuleProvideInfo.of(map(mp.provides().asSymbol()),
 76                                         mp.providesWith().stream().map(pw ->
 77                                                 map(pw.asSymbol())).toList())).toList()));
 78             case NestHostAttribute nha ->
 79                 clb.with(NestHostAttribute.of(map(nha.nestHost().asSymbol())));
 80             case NestMembersAttribute nma ->
 81                 clb.with(NestMembersAttribute.ofSymbols(nma.nestMembers().stream()
 82                         .map(nm -> map(nm.asSymbol())).toList()));
 83             case PermittedSubclassesAttribute psa ->
 84                 clb.with(PermittedSubclassesAttribute.ofSymbols(
 85                         psa.permittedSubclasses().stream().map(ps ->
 86                                 map(ps.asSymbol())).toList()));
 87             case LoadableDescriptorsAttribute pa ->
 88                 clb.with(LoadableDescriptorsAttribute.ofSymbols(
 89                         pa.loadableDescriptorSymbols().stream()
 90                                 .map(this::map).toList()));
 91             case RuntimeVisibleAnnotationsAttribute aa ->
 92                 clb.with(RuntimeVisibleAnnotationsAttribute.of(
 93                         mapAnnotations(aa.annotations())));
 94             case RuntimeInvisibleAnnotationsAttribute aa ->
 95                 clb.with(RuntimeInvisibleAnnotationsAttribute.of(
 96                         mapAnnotations(aa.annotations())));
 97             case RuntimeVisibleTypeAnnotationsAttribute aa ->
 98                 clb.with(RuntimeVisibleTypeAnnotationsAttribute.of(
 99                         mapTypeAnnotations(aa.annotations())));
100             case RuntimeInvisibleTypeAnnotationsAttribute aa ->
101                 clb.with(RuntimeInvisibleTypeAnnotationsAttribute.of(
102                         mapTypeAnnotations(aa.annotations())));
103             default ->
104                 clb.with(cle);
105         }
106     }
107 
108     @Override
109     public FieldTransform asFieldTransform() {
110         return (FieldBuilder fb, FieldElement fe) -> {
< prev index next >