diff --git a/src/soot/coffi/ClassFile.java b/src/soot/coffi/ClassFile.java index f4d2f1097ed..8ddb347ccbc 100644 --- a/src/soot/coffi/ClassFile.java +++ b/src/soot/coffi/ClassFile.java @@ -705,7 +705,20 @@ else if (s.compareTo(attribute_info.EnclosingMethod)==0){ ea.method_index = d.readUnsignedShort(); a = (attribute_info)ea; } - else if(s.compareTo(attribute_info.InnerClasses)==0) + else if (s.compareTo(attribute_info.NestHost)==0){ + NestHost_attribute ea = new NestHost_attribute(); + ea.class_index = d.readUnsignedShort(); + a = (attribute_info)ea; + } + else if (s.compareTo(attribute_info.NestMembers)==0){ + NestMembers_attribute ea = new NestMembers_attribute(); + int number_of_classes = d.readUnsignedShort(); + ea.classes = new int[number_of_classes]; + for (int idx = 0; idx < number_of_classes; idx++) + ea.classes[idx] = d.readUnsignedShort(); + a = (attribute_info)ea; + } + else if(s.compareTo(attribute_info.InnerClasses)==0) { InnerClasses_attribute ia = new InnerClasses_attribute(); ia.inner_classes_length = d.readUnsignedShort(); diff --git a/src/soot/coffi/NestHost_attribute.java b/src/soot/coffi/NestHost_attribute.java new file mode 100644 index 00000000000..a6e1a1ad0fc --- /dev/null +++ b/src/soot/coffi/NestHost_attribute.java @@ -0,0 +1,35 @@ +/* Soot - a J*va Optimization Framework + * Copyright (C) 2005 Jennifer Lhotak + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* + * Modified by the Sable Research Group and others 1997-1999. + * See the 'credits' file distributed with Soot for the complete list of + * contributors. (Soot is distributed at http://www.sable.mcgill.ca/soot) + */ + +package soot.coffi; + +/** Attribute that connects nest member with its host + * @see attribute_info + * @author Demyan Kimitsa + */ +class NestHost_attribute extends attribute_info { + public int class_index; +} + diff --git a/src/soot/coffi/NestMembers_attribute.java b/src/soot/coffi/NestMembers_attribute.java new file mode 100644 index 00000000000..0a7e63c4d36 --- /dev/null +++ b/src/soot/coffi/NestMembers_attribute.java @@ -0,0 +1,35 @@ +/* Soot - a J*va Optimization Framework + * Copyright (C) 2005 Jennifer Lhotak + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* + * Modified by the Sable Research Group and others 1997-1999. + * See the 'credits' file distributed with Soot for the complete list of + * contributors. (Soot is distributed at http://www.sable.mcgill.ca/soot) + */ + +package soot.coffi; + +/** Attribute that connects nest host with members + * @see attribute_info + * @author Demyan Kimitsa + */ +class NestMembers_attribute extends attribute_info { + public int[] classes; +} + diff --git a/src/soot/coffi/Util.java b/src/soot/coffi/Util.java index 830031b1852..120a6e8e701 100644 --- a/src/soot/coffi/Util.java +++ b/src/soot/coffi/Util.java @@ -409,6 +409,18 @@ else if (coffiClass.attributes[i] instanceof EnclosingMethod_attribute){ } bclass.addTag(new EnclosingMethodTag(class_name, method_name, method_sig)); } + else if (coffiClass.attributes[i] instanceof NestHost_attribute) { + NestHost_attribute attr = (NestHost_attribute)coffiClass.attributes[i]; + String nest_host_class = ((CONSTANT_Utf8_info)coffiClass.constant_pool[((CONSTANT_Class_info)coffiClass.constant_pool[ attr.class_index]).name_index]).convert(); + bclass.addTag(new NestHostTag(nest_host_class)); + } + else if (coffiClass.attributes[i] instanceof NestMembers_attribute) { + NestMembers_attribute attr = (NestMembers_attribute)coffiClass.attributes[i]; + String[] members = new String[attr.classes.length]; + for (int idx = 0; idx < members.length; idx++) + members[idx] = ((CONSTANT_Utf8_info)coffiClass.constant_pool[((CONSTANT_Class_info)coffiClass.constant_pool[ attr.classes[idx]]).name_index]).convert(); + bclass.addTag(new NestMembersTag(members)); + } else if (coffiClass.attributes[i] instanceof RuntimeVisibleAnnotations_attribute || coffiClass.attributes[i] instanceof RuntimeInvisibleAnnotations_attribute) { addAnnotationVisibilityAttribute(bclass, coffiClass.attributes[i], coffiClass, references); diff --git a/src/soot/coffi/attribute_info.java b/src/soot/coffi/attribute_info.java index f2e0023d105..3e5aac2f146 100644 --- a/src/soot/coffi/attribute_info.java +++ b/src/soot/coffi/attribute_info.java @@ -91,7 +91,17 @@ class attribute_info { * @see EnclosingMethod_attribute */ public static final String EnclosingMethod = "EnclosingMethod"; - + + /** String by which a NestMembers attribute is recognized. + * @see NestMembers_attribute + */ + public static final String NestMembers = "NestMembers"; + + /** String by which a NestHost attribute is recognized. + * @see NestHost_attribute + */ + public static final String NestHost = "NestHost"; + /** String by which a LocalVariableTypeTable attribute is recognized. * @see LocalVariableTypeTable_attribute */ diff --git a/src/soot/jimple/toolkits/pointer/LocalMustAliasAnalysis.java b/src/soot/jimple/toolkits/pointer/LocalMustAliasAnalysis.java index b1fd82e8d2c..fd2cc082998 100644 --- a/src/soot/jimple/toolkits/pointer/LocalMustAliasAnalysis.java +++ b/src/soot/jimple/toolkits/pointer/LocalMustAliasAnalysis.java @@ -27,7 +27,6 @@ import java.util.Map; import java.util.Set; -import org.omg.CORBA.UNKNOWN; import soot.EquivalentValue; import soot.Local; diff --git a/src/soot/tagkit/NestHostTag.java b/src/soot/tagkit/NestHostTag.java new file mode 100644 index 00000000000..d2068b4a215 --- /dev/null +++ b/src/soot/tagkit/NestHostTag.java @@ -0,0 +1,58 @@ +/* Soot - a J*va Optimization Framework + * Copyright (C) 2003 Archie L. Cobbs + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* + * Modified by the Sable Research Group and others 1997-1999. + * See the 'credits' file distributed with Soot for the complete list of + * contributors. (Soot is distributed at http://www.sable.mcgill.ca/soot) + */ + + +package soot.tagkit; + +/** + * Tag keeps nest host for class (added in java 11) + * + * @author dkimitsa + */ +public class NestHostTag implements Tag { + private final String nestHostClass; + + public NestHostTag(String nestHostClass) { + this.nestHostClass = nestHostClass; + } + + public String getName() { + return "NestHostTag"; + } + + public byte[] getValue() { + return new byte[0]; + } + + + public String getNestHostClass() { + return nestHostClass; + } + + public String toString() { + return "[host=" + nestHostClass + "]"; + } +} + diff --git a/src/soot/tagkit/NestMembersTag.java b/src/soot/tagkit/NestMembersTag.java new file mode 100644 index 00000000000..9b44663d7c9 --- /dev/null +++ b/src/soot/tagkit/NestMembersTag.java @@ -0,0 +1,57 @@ +/* Soot - a J*va Optimization Framework + * Copyright (C) 2003 Archie L. Cobbs + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* + * Modified by the Sable Research Group and others 1997-1999. + * See the 'credits' file distributed with Soot for the complete list of + * contributors. (Soot is distributed at http://www.sable.mcgill.ca/soot) + */ + + +package soot.tagkit; + +/** + * Tag keeps nest members for class (added in java 11) + * + * @author dkimitsa + */ +public class NestMembersTag implements Tag { + private final String[] nestMembers; + + public NestMembersTag(String[] nestMembers) { + this.nestMembers = nestMembers; + } + + public String getName() { + return "NestMembersTag"; + } + + public byte[] getValue() { + return new byte[0]; + } + + public String[] getNestMembers() { + return nestMembers; + } + + public String toString() { + return "[members=" + String.join(",", nestMembers); + } +} +