cprover
java_bytecode_convert_class.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: JAVA Bytecode Language Conversion
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
11 
13 
14 #ifdef DEBUG
15 #include <iostream>
16 #endif
17 
18 #include "java_root_class.h"
19 #include "java_types.h"
21 #include "java_bytecode_language.h"
22 #include "java_utils.h"
23 
25 
26 #include <util/arith_tools.h>
27 #include <util/c_types.h>
28 #include <util/expr_initializer.h>
29 #include <util/namespace.h>
30 #include <util/prefix.h>
31 #include <util/std_expr.h>
32 #include <util/suffix.h>
33 
35 {
36 public:
38  symbol_tablet &_symbol_table,
39  message_handlert &_message_handler,
40  size_t _max_array_length,
42  java_string_library_preprocesst &_string_preprocess,
43  const std::unordered_set<std::string> &no_load_classes)
44  : messaget(_message_handler),
45  symbol_table(_symbol_table),
46  max_array_length(_max_array_length),
48  string_preprocess(_string_preprocess),
50  {
51  }
52 
68  void operator()(
70  {
71  PRECONDITION(!parse_trees.empty());
72  const java_bytecode_parse_treet &parse_tree = parse_trees.front();
73 
74  // Add array types to the symbol table
76 
77  const bool loading_success =
78  parse_tree.loading_successful &&
79  !no_load_classes.count(id2string(parse_tree.parsed_class.name));
80  if(loading_success)
81  {
82  overlay_classest overlay_classes;
83  for(auto overlay_class_it = std::next(parse_trees.begin());
84  overlay_class_it != parse_trees.end();
85  ++overlay_class_it)
86  {
87  overlay_classes.push_front(std::cref(overlay_class_it->parsed_class));
88  }
89  convert(parse_tree.parsed_class, overlay_classes);
90  }
91 
92  // Add as string type if relevant
93  const irep_idt &class_name = parse_tree.parsed_class.name;
96  else if(!loading_success)
97  // Generate stub if couldn't load from bytecode and wasn't string type
99  class_name,
100  symbol_table,
103  }
104 
109 
110 private:
112  const size_t max_array_length;
115 
116  // conversion
117  typedef std::list<std::reference_wrapper<const classt>> overlay_classest;
118  void convert(const classt &c, const overlay_classest &overlay_classes);
119  void convert(symbolt &class_symbol, const fieldt &f);
120 
136  static bool is_overlay_method(const methodt &method)
137  {
138  return method.has_annotation(ID_overlay_method);
139  }
140 
161  static bool is_ignored_method(
162  const irep_idt &class_name, const methodt &method)
163  {
164  static irep_idt org_cprover_CProver_name = "org.cprover.CProver";
165  return
166  (class_name == org_cprover_CProver_name &&
167  cprover_methods_to_ignore.count(id2string(method.name)) != 0) ||
168  method.has_annotation(ID_ignored_method);
169  }
170 
171  bool check_field_exists(
172  const fieldt &field,
173  const irep_idt &qualified_fieldname,
174  const struct_union_typet::componentst &fields) const;
175 
176  std::unordered_set<std::string> no_load_classes;
177 };
178 
191 {
192  if(signature.has_value())
193  {
194  // skip the (potential) list of generic parameters at the beginning of the
195  // signature
196  const size_t start =
197  signature.value().front() == '<'
198  ? find_closing_delimiter(signature.value(), 0, '<', '>') + 1
199  : 0;
200 
201  // extract the superclass reference
202  const size_t end =
203  find_closing_semi_colon_for_reference_type(signature.value(), start);
204  const std::string superclass_ref =
205  signature.value().substr(start, (end - start) + 1);
206 
207  // if the superclass is generic then the reference is of form
208  // `Lsuperclass-name<generic-types;>;` if it is implicitly generic, then the
209  // reference is of the form
210  // `Lsuperclass-name<Tgeneric-types;>.Innerclass-Name`
211  if(superclass_ref.find('<') != std::string::npos)
212  return superclass_ref;
213  }
214  return {};
215 }
216 
230  const optionalt<std::string> &signature,
231  const std::string &interface_name)
232 {
233  if(signature.has_value())
234  {
235  // skip the (potential) list of generic parameters at the beginning of the
236  // signature
237  size_t start =
238  signature.value().front() == '<'
239  ? find_closing_delimiter(signature.value(), 0, '<', '>') + 1
240  : 0;
241 
242  // skip the superclass reference (if there is at least one interface
243  // reference in the signature, then there is a superclass reference)
244  start =
245  find_closing_semi_colon_for_reference_type(signature.value(), start) + 1;
246 
247  // if the interface name includes package name, convert dots to slashes
248  std::string interface_name_slash_to_dot = interface_name;
249  std::replace(
250  interface_name_slash_to_dot.begin(),
251  interface_name_slash_to_dot.end(),
252  '.',
253  '/');
254 
255  start =
256  signature.value().find("L" + interface_name_slash_to_dot + "<", start);
257  if(start != std::string::npos)
258  {
259  const size_t &end =
260  find_closing_semi_colon_for_reference_type(signature.value(), start);
261  return signature.value().substr(start, (end - start) + 1);
262  }
263  }
264  return {};
265 }
266 
271  const classt &c,
272  const overlay_classest &overlay_classes)
273 {
274  std::string qualified_classname="java::"+id2string(c.name);
275  if(symbol_table.has_symbol(qualified_classname))
276  {
277  debug() << "Skip class " << c.name << " (already loaded)" << eom;
278  return;
279  }
280 
281  java_class_typet class_type;
282  if(c.signature.has_value() && c.signature.value()[0]=='<')
283  {
284  java_generic_class_typet generic_class_type;
285 #ifdef DEBUG
286  std::cout << "INFO: found generic class signature "
287  << c.signature.value()
288  << " in parsed class "
289  << c.name << "\n";
290 #endif
291  try
292  {
293  const std::vector<typet> &generic_types=java_generic_type_from_string(
294  id2string(c.name),
295  c.signature.value());
296  for(const typet &t : generic_types)
297  {
298  generic_class_type.generic_types()
299  .push_back(to_java_generic_parameter(t));
300  }
301  class_type=generic_class_type;
302  }
304  {
305  debug() << "Class: " << c.name
306  << "\n could not parse signature: " << c.signature.value()
307  << "\n " << e.what() << "\n ignoring that the class is generic"
308  << eom;
309  }
310  }
311 
312  class_type.set_tag(c.name);
313  class_type.set_inner_name(c.inner_name);
314  class_type.set_abstract(c.is_abstract);
315  class_type.set_is_annotation(c.is_annotation);
316  class_type.set_interface(c.is_interface);
317  class_type.set_synthetic(c.is_synthetic);
318  class_type.set_final(c.is_final);
319  class_type.set_is_inner_class(c.is_inner_class);
320  class_type.set_is_static_class(c.is_static_class);
322  class_type.set_outer_class(c.outer_class);
323  class_type.set_super_class(c.super_class);
324  if(c.is_enum)
325  {
327  {
328  warning() << "Java Enum " << c.name << " won't work properly because max "
329  << "array length (" << max_array_length << ") is less than the "
330  << "enum size (" << c.enum_elements << ")" << eom;
331  }
332  class_type.set(
333  ID_java_enum_static_unwind,
335  class_type.set_is_enumeration(true);
336  }
337 
338  if(c.is_public)
339  class_type.set_access(ID_public);
340  else if(c.is_protected)
341  class_type.set_access(ID_protected);
342  else if(c.is_private)
343  class_type.set_access(ID_private);
344  else
345  class_type.set_access(ID_default);
346 
347  if(!c.super_class.empty())
348  {
349  const struct_tag_typet base("java::" + id2string(c.super_class));
350 
351  // if the superclass is generic then the class has the superclass reference
352  // including the generic info in its signature
353  // e.g., signature for class 'A<T>' that extends
354  // 'Generic<Integer>' is '<T:Ljava/lang/Object;>LGeneric<LInteger;>;'
355  const optionalt<std::string> &superclass_ref =
357  if(superclass_ref.has_value())
358  {
359  try
360  {
361  const java_generic_struct_tag_typet generic_base(
362  base, superclass_ref.value(), qualified_classname);
363  class_type.add_base(generic_base);
364  }
366  {
367  debug() << "Superclass: " << c.super_class << " of class: " << c.name
368  << "\n could not parse signature: " << superclass_ref.value()
369  << "\n " << e.what()
370  << "\n ignoring that the superclass is generic" << eom;
371  class_type.add_base(base);
372  }
373  }
374  else
375  {
376  class_type.add_base(base);
377  }
378  java_class_typet::componentt base_class_field;
379  base_class_field.type() = class_type.bases().at(0).type();
380  base_class_field.set_name("@" + id2string(c.super_class));
381  base_class_field.set_base_name("@" + id2string(c.super_class));
382  base_class_field.set_pretty_name("@" + id2string(c.super_class));
383  class_type.components().push_back(base_class_field);
384  }
385 
386  // interfaces are recorded as bases
387  for(const auto &interface : c.implements)
388  {
389  const struct_tag_typet base("java::" + id2string(interface));
390 
391  // if the interface is generic then the class has the interface reference
392  // including the generic info in its signature
393  // e.g., signature for class 'A implements GenericInterface<Integer>' is
394  // 'Ljava/lang/Object;LGenericInterface<LInteger;>;'
395  const optionalt<std::string> interface_ref =
397  if(interface_ref.has_value())
398  {
399  try
400  {
401  const java_generic_struct_tag_typet generic_base(
402  base, interface_ref.value(), qualified_classname);
403  class_type.add_base(generic_base);
404  }
406  {
407  debug() << "Interface: " << interface << " of class: " << c.name
408  << "\n could not parse signature: " << interface_ref.value()
409  << "\n " << e.what()
410  << "\n ignoring that the interface is generic" << eom;
411  class_type.add_base(base);
412  }
413  }
414  else
415  {
416  class_type.add_base(base);
417  }
418  }
419 
420  // now do lambda method handles (bootstrap methods)
421  for(const auto &lambda_entry : c.lambda_method_handle_map)
422  {
423  // if the handle is of unknown type, we still need to store it to preserve
424  // the correct indexing (invokedynamic instructions will retrieve
425  // method handles by index)
426  lambda_entry.second.is_unknown_handle()
427  ? class_type.add_unknown_lambda_method_handle()
428  : class_type.add_lambda_method_handle(
429  "java::" + id2string(lambda_entry.second.lambda_method_ref));
430  }
431 
432  // Load annotations
433  if(!c.annotations.empty())
434  convert_annotations(c.annotations, class_type.get_annotations());
435 
436  // the base name is the name of the class without the package
437  const irep_idt base_name = [](const std::string &full_name) {
438  const size_t last_dot = full_name.find_last_of('.');
439  return last_dot == std::string::npos
440  ? full_name
441  : std::string(full_name, last_dot + 1, std::string::npos);
442  }(id2string(c.name));
443 
444  // produce class symbol
445  symbolt new_symbol;
446  new_symbol.base_name = base_name;
447  new_symbol.pretty_name=c.name;
448  new_symbol.name=qualified_classname;
449  class_type.set_name(new_symbol.name);
450  new_symbol.type=class_type;
451  new_symbol.mode=ID_java;
452  new_symbol.is_type=true;
453 
454  symbolt *class_symbol;
455 
456  // add before we do members
457  debug() << "Adding symbol: class '" << c.name << "'" << eom;
458  if(symbol_table.move(new_symbol, class_symbol))
459  {
460  error() << "failed to add class symbol " << new_symbol.name << eom;
461  throw 0;
462  }
463 
464  // Now do fields
465  const class_typet::componentst &fields =
466  to_class_type(class_symbol->type).components();
467  // Include fields from overlay classes as they will be required by the
468  // methods defined there
469  for(auto overlay_class : overlay_classes)
470  {
471  for(const auto &field : overlay_class.get().fields)
472  {
473  std::string field_id = qualified_classname + "." + id2string(field.name);
474  if(check_field_exists(field, field_id, fields))
475  {
476  std::string err =
477  "Duplicate field definition for " + field_id + " in overlay class";
478  // TODO: This could just be a warning if the types match
479  error() << err << eom;
480  throw err.c_str();
481  }
482  debug()
483  << "Adding symbol from overlay class: field '" << field.name << "'"
484  << eom;
485  convert(*class_symbol, field);
486  POSTCONDITION(check_field_exists(field, field_id, fields));
487  }
488  }
489  for(const auto &field : c.fields)
490  {
491  std::string field_id = qualified_classname + "." + id2string(field.name);
492  if(check_field_exists(field, field_id, fields))
493  {
494  // TODO: This could be a warning if the types match
495  error()
496  << "Field definition for " << field_id
497  << " already loaded from overlay class" << eom;
498  continue;
499  }
500  debug() << "Adding symbol: field '" << field.name << "'" << eom;
501  convert(*class_symbol, field);
502  POSTCONDITION(check_field_exists(field, field_id, fields));
503  }
504 
505  // Now do methods
506  std::set<irep_idt> overlay_methods;
507  for(auto overlay_class : overlay_classes)
508  {
509  for(const methodt &method : overlay_class.get().methods)
510  {
511  const irep_idt method_identifier =
512  qualified_classname + "." + id2string(method.name)
513  + ":" + method.descriptor;
514  if(is_ignored_method(c.name, method))
515  {
516  debug()
517  << "Ignoring method: '" << method_identifier << "'"
518  << eom;
519  continue;
520  }
521  if(method_bytecode.contains_method(method_identifier))
522  {
523  // This method has already been discovered and added to method_bytecode
524  // while parsing an overlay class that appears later in the classpath
525  // (we're working backwards)
526  // Warn the user if the definition already found was not an overlay,
527  // otherwise simply don't load this earlier definition
528  if(overlay_methods.count(method_identifier) == 0)
529  {
530  // This method was defined in a previous class definition without
531  // being marked as an overlay method
532  warning()
533  << "Method " << method_identifier
534  << " exists in an overlay class without being marked as an "
535  "overlay and also exists in another overlay class that appears "
536  "earlier in the classpath"
537  << eom;
538  }
539  continue;
540  }
541  // Always run the lazy pre-stage, as it symbol-table
542  // registers the function.
543  debug()
544  << "Adding symbol from overlay class: method '" << method_identifier
545  << "'" << eom;
546  java_bytecode_convert_method_lazy(
547  *class_symbol,
548  method_identifier,
549  method,
550  symbol_table,
551  get_message_handler());
552  method_bytecode.add(qualified_classname, method_identifier, method);
553  if(is_overlay_method(method))
554  overlay_methods.insert(method_identifier);
555  }
556  }
557  for(const methodt &method : c.methods)
558  {
559  const irep_idt method_identifier=
560  qualified_classname + "." + id2string(method.name)
561  + ":" + method.descriptor;
562  if(is_ignored_method(c.name, method))
563  {
564  debug()
565  << "Ignoring method: '" << method_identifier << "'"
566  << eom;
567  continue;
568  }
569  if(method_bytecode.contains_method(method_identifier))
570  {
571  // This method has already been discovered while parsing an overlay
572  // class
573  // If that definition is an overlay then we simply don't load this
574  // original definition and we remove it from the list of overlays
575  if(overlay_methods.erase(method_identifier) == 0)
576  {
577  // This method was defined in a previous class definition without
578  // being marked as an overlay method
579  warning()
580  << "Method " << method_identifier
581  << " exists in an overlay class without being marked as an overlay "
582  "and also exists in the underlying class"
583  << eom;
584  }
585  continue;
586  }
587  // Always run the lazy pre-stage, as it symbol-table
588  // registers the function.
589  debug() << "Adding symbol: method '" << method_identifier << "'" << eom;
590  java_bytecode_convert_method_lazy(
591  *class_symbol,
592  method_identifier,
593  method,
594  symbol_table,
595  get_message_handler());
596  method_bytecode.add(qualified_classname, method_identifier, method);
597  if(is_overlay_method(method))
598  {
599  warning()
600  << "Method " << method_identifier
601  << " marked as an overlay where defined in the underlying class" << eom;
602  }
603  }
604  if(!overlay_methods.empty())
605  {
606  error()
607  << "Overlay methods defined in overlay classes did not exist in the "
608  "underlying class:\n";
609  for(const irep_idt &method_id : overlay_methods)
610  error() << " " << method_id << "\n";
611  error() << eom;
612  }
613 
614  // is this a root class?
615  if(c.super_class.empty())
616  java_root_class(*class_symbol);
617 }
618 
619 bool java_bytecode_convert_classt::check_field_exists(
620  const java_bytecode_parse_treet::fieldt &field,
621  const irep_idt &qualified_fieldname,
622  const struct_union_typet::componentst &fields) const
623 {
624  if(field.is_static)
625  return symbol_table.has_symbol(qualified_fieldname);
626 
627  auto existing_field = std::find_if(
628  fields.begin(),
629  fields.end(),
630  [&field](const struct_union_typet::componentt &f)
631  {
632  return f.get_name() == field.name;
633  });
634  return existing_field != fields.end();
635 }
636 
640 void java_bytecode_convert_classt::convert(
641  symbolt &class_symbol,
642  const fieldt &f)
643 {
644  typet field_type;
645  if(f.signature.has_value())
646  {
647  field_type = *java_type_from_string_with_exception(
648  f.descriptor, f.signature, id2string(class_symbol.name));
649 
651  if(is_java_generic_parameter(field_type))
652  {
653 #ifdef DEBUG
654  std::cout << "fieldtype: generic "
655  << to_java_generic_parameter(field_type).type_variable()
656  .get_identifier()
657  << " name " << f.name << "\n";
658 #endif
659  }
660 
663  else if(is_java_generic_type(field_type))
664  {
665  java_generic_typet &with_gen_type=
666  to_java_generic_type(field_type);
667 #ifdef DEBUG
668  std::cout << "fieldtype: generic container type "
669  << std::to_string(with_gen_type.generic_type_arguments().size())
670  << " type " << with_gen_type.id()
671  << " name " << f.name
672  << " subtype id " << with_gen_type.subtype().id() << "\n";
673 #endif
674  field_type=with_gen_type;
675  }
676  }
677  else
678  field_type = *java_type_from_string(f.descriptor);
679 
680  // determine access
681  irep_idt access;
682 
683  if(f.is_private)
684  access = ID_private;
685  else if(f.is_protected)
686  access = ID_protected;
687  else if(f.is_public)
688  access = ID_public;
689  else
690  access = ID_default;
691 
692  auto &class_type = to_java_class_type(class_symbol.type);
693 
694  // is this a static field?
695  if(f.is_static)
696  {
697  const irep_idt field_identifier =
698  id2string(class_symbol.name) + "." + id2string(f.name);
699 
700  class_type.static_members().emplace_back();
701  auto &component = class_type.static_members().back();
702 
703  component.set_name(field_identifier);
704  component.set_base_name(f.name);
705  component.set_pretty_name(f.name);
706  component.set_access(access);
707  component.set_is_final(f.is_final);
708  component.type() = field_type;
709 
710  // Create the symbol
711  symbolt new_symbol;
712 
713  new_symbol.is_static_lifetime=true;
714  new_symbol.is_lvalue=true;
715  new_symbol.is_state_var=true;
716  new_symbol.name=id2string(class_symbol.name)+"."+id2string(f.name);
717  new_symbol.base_name=f.name;
718  new_symbol.type=field_type;
719  // Provide a static field -> class link, like
720  // java_bytecode_convert_method::convert does for method -> class.
721  set_declaring_class(new_symbol, class_symbol.name);
722  new_symbol.type.set(ID_C_field, f.name);
723  new_symbol.type.set(ID_C_constant, f.is_final);
724  new_symbol.pretty_name=id2string(class_symbol.pretty_name)+
725  "."+id2string(f.name);
726  new_symbol.mode=ID_java;
727  new_symbol.is_type=false;
728 
729  // These annotations use `ID_C_access` instead of `ID_access` like methods
730  // to avoid type clashes in expressions like `some_static_field = 0`, where
731  // with ID_access the constant '0' would need to have an access modifier
732  // too, or else appear to have incompatible type.
733  if(f.is_public)
734  new_symbol.type.set(ID_C_access, ID_public);
735  else if(f.is_protected)
736  new_symbol.type.set(ID_C_access, ID_protected);
737  else if(f.is_private)
738  new_symbol.type.set(ID_C_access, ID_private);
739  else
740  new_symbol.type.set(ID_C_access, ID_default);
741 
742  const namespacet ns(symbol_table);
743  const auto value = zero_initializer(field_type, class_symbol.location, ns);
744  if(!value.has_value())
745  {
746  error().source_location = class_symbol.location;
747  error() << "failed to zero-initialize " << f.name << eom;
748  throw 0;
749  }
750  new_symbol.value = *value;
751 
752  // Load annotations
753  if(!f.annotations.empty())
754  {
755  convert_annotations(
756  f.annotations,
757  type_checked_cast<annotated_typet>(new_symbol.type).get_annotations());
758  }
759 
760  // Do we have the static field symbol already?
761  const auto s_it=symbol_table.symbols.find(new_symbol.name);
762  if(s_it!=symbol_table.symbols.end())
763  symbol_table.erase(s_it); // erase, we stubbed it
764 
765  if(symbol_table.add(new_symbol))
766  assert(false && "failed to add static field symbol");
767  }
768  else
769  {
770  class_type.components().emplace_back();
771  auto &component = class_type.components().back();
772 
773  component.set_name(f.name);
774  component.set_base_name(f.name);
775  component.set_pretty_name(f.name);
776  component.set_access(access);
777  component.set_is_final(f.is_final);
778  component.type() = field_type;
779 
780  // Load annotations
781  if(!f.annotations.empty())
782  {
783  convert_annotations(
784  f.annotations,
785  static_cast<annotated_typet &>(component.type()).get_annotations());
786  }
787  }
788 }
789 
790 void add_java_array_types(symbol_tablet &symbol_table)
791 {
792  const std::string letters="ijsbcfdza";
793 
794  for(const char l : letters)
795  {
796  struct_tag_typet struct_tag_type =
797  to_struct_tag_type(java_array_type(l).subtype());
798 
799  const irep_idt &struct_tag_type_identifier =
800  struct_tag_type.get_identifier();
801  if(symbol_table.has_symbol(struct_tag_type_identifier))
802  return;
803 
804  java_class_typet class_type;
805  // we have the base class, java.lang.Object, length and data
806  // of appropriate type
807  class_type.set_tag(struct_tag_type_identifier);
808  // Note that non-array types don't have "java::" at the beginning of their
809  // tag, and their name is "java::" + their tag. Since arrays do have
810  // "java::" at the beginning of their tag we set the name to be the same as
811  // the tag.
812  class_type.set_name(struct_tag_type_identifier);
813 
814  class_type.components().reserve(3);
815  java_class_typet::componentt base_class_component(
816  "@java.lang.Object", struct_tag_typet("java::java.lang.Object"));
817  base_class_component.set_pretty_name("@java.lang.Object");
818  base_class_component.set_base_name("@java.lang.Object");
819  class_type.components().push_back(base_class_component);
820 
821  java_class_typet::componentt length_component("length", java_int_type());
822  length_component.set_pretty_name("length");
823  length_component.set_base_name("length");
824  class_type.components().push_back(length_component);
825 
826  java_class_typet::componentt data_component(
827  "data", java_reference_type(java_type_from_char(l)));
828  data_component.set_pretty_name("data");
829  data_component.set_base_name("data");
830  class_type.components().push_back(data_component);
831 
832  if(l == 'a')
833  {
834  // This is a reference array (java::array[reference]). Add extra fields to
835  // carry the innermost element type and array dimension.
836  java_class_typet::componentt array_element_classid_component(
837  JAVA_ARRAY_ELEMENT_CLASSID_FIELD_NAME, string_typet());
838  array_element_classid_component.set_pretty_name(
839  JAVA_ARRAY_ELEMENT_CLASSID_FIELD_NAME);
840  array_element_classid_component.set_base_name(
841  JAVA_ARRAY_ELEMENT_CLASSID_FIELD_NAME);
842  class_type.components().push_back(array_element_classid_component);
843 
844  java_class_typet::componentt array_dimension_component(
845  JAVA_ARRAY_DIMENSION_FIELD_NAME, java_int_type());
846  array_dimension_component.set_pretty_name(
847  JAVA_ARRAY_DIMENSION_FIELD_NAME);
848  array_dimension_component.set_base_name(JAVA_ARRAY_DIMENSION_FIELD_NAME);
849  class_type.components().push_back(array_dimension_component);
850  }
851 
852  class_type.add_base(struct_tag_typet("java::java.lang.Object"));
853 
854  INVARIANT(
855  is_valid_java_array(class_type),
856  "Constructed a new type representing a Java Array "
857  "object that doesn't match expectations");
858 
859  symbolt symbol;
860  symbol.name = struct_tag_type_identifier;
861  symbol.base_name = struct_tag_type.get(ID_C_base_name);
862  symbol.is_type=true;
863  symbol.type = class_type;
864  symbol.mode = ID_java;
865  symbol_table.add(symbol);
866 
867  // Also provide a clone method:
868  // ----------------------------
869 
870  const irep_idt clone_name =
871  id2string(struct_tag_type_identifier) + ".clone:()Ljava/lang/Object;";
872  java_method_typet::parametert this_param(
873  java_reference_type(struct_tag_type));
874  this_param.set_identifier(id2string(clone_name)+"::this");
875  this_param.set_base_name(ID_this);
876  this_param.set_this();
877  const java_method_typet clone_type({this_param}, java_lang_object_type());
878 
879  parameter_symbolt this_symbol;
880  this_symbol.name=this_param.get_identifier();
881  this_symbol.base_name=this_param.get_base_name();
882  this_symbol.pretty_name=this_symbol.base_name;
883  this_symbol.type=this_param.type();
884  this_symbol.mode=ID_java;
885  symbol_table.add(this_symbol);
886 
887  const irep_idt local_name=
888  id2string(clone_name)+"::cloned_array";
889  auxiliary_symbolt local_symbol;
890  local_symbol.name=local_name;
891  local_symbol.base_name="cloned_array";
892  local_symbol.pretty_name=local_symbol.base_name;
893  local_symbol.type = java_reference_type(struct_tag_type);
894  local_symbol.mode=ID_java;
895  symbol_table.add(local_symbol);
896  const auto local_symexpr = local_symbol.symbol_expr();
897 
898  code_declt declare_cloned(local_symexpr);
899 
900  source_locationt location;
901  location.set_function(local_name);
902  side_effect_exprt java_new_array(
903  ID_java_new_array, java_reference_type(struct_tag_type), location);
904  dereference_exprt old_array{this_symbol.symbol_expr()};
905  dereference_exprt new_array{local_symexpr};
906  member_exprt old_length(
907  old_array, length_component.get_name(), length_component.type());
908  java_new_array.copy_to_operands(old_length);
909  code_assignt create_blank(local_symexpr, java_new_array);
910 
911  codet copy_type_information = code_skipt();
912  if(l == 'a')
913  {
914  // Reference arrays carry additional type information in their classids
915  // which should be copied:
916  const auto &array_dimension_component =
917  class_type.get_component(JAVA_ARRAY_DIMENSION_FIELD_NAME);
918  const auto &array_element_classid_component =
919  class_type.get_component(JAVA_ARRAY_ELEMENT_CLASSID_FIELD_NAME);
920 
921  member_exprt old_array_dimension(old_array, array_dimension_component);
922  member_exprt old_array_element_classid(
923  old_array, array_element_classid_component);
924 
925  member_exprt new_array_dimension(new_array, array_dimension_component);
926  member_exprt new_array_element_classid(
927  new_array, array_element_classid_component);
928 
929  copy_type_information = code_blockt{
930  {code_assignt(new_array_dimension, old_array_dimension),
931  code_assignt(new_array_element_classid, old_array_element_classid)}};
932  }
933 
934  member_exprt old_data(
935  old_array, data_component.get_name(), data_component.type());
936  member_exprt new_data(
937  new_array, data_component.get_name(), data_component.type());
938 
939  /*
940  // TODO use this instead of a loop.
941  codet array_copy;
942  array_copy.set_statement(ID_array_copy);
943  array_copy.add_to_operands(std::move(new_data), std::move(old_data));
944  clone_body.add_to_operands(std::move(array_copy));
945  */
946 
947  // Begin for-loop to replace:
948 
949  const irep_idt index_name=
950  id2string(clone_name)+"::index";
951  auxiliary_symbolt index_symbol;
952  index_symbol.name=index_name;
953  index_symbol.base_name="index";
954  index_symbol.pretty_name=index_symbol.base_name;
955  index_symbol.type = length_component.type();
956  index_symbol.mode=ID_java;
957  symbol_table.add(index_symbol);
958  const auto &index_symexpr=index_symbol.symbol_expr();
959 
960  code_declt declare_index(index_symexpr);
961 
962  dereference_exprt old_cell(
963  plus_exprt(old_data, index_symexpr), old_data.type().subtype());
964  dereference_exprt new_cell(
965  plus_exprt(new_data, index_symexpr), new_data.type().subtype());
966 
967  const code_fort copy_loop = code_fort::from_index_bounds(
968  from_integer(0, index_symexpr.type()),
969  old_length,
970  index_symexpr,
971  code_assignt(std::move(new_cell), std::move(old_cell)),
972  location);
973 
974  member_exprt new_base_class(
975  new_array, base_class_component.get_name(), base_class_component.type());
976  address_of_exprt retval(new_base_class);
977  code_returnt return_inst(retval);
978 
979  const code_blockt clone_body({declare_cloned,
980  create_blank,
981  copy_type_information,
982  declare_index,
983  copy_loop,
984  return_inst});
985 
986  symbolt clone_symbol;
987  clone_symbol.name=clone_name;
988  clone_symbol.pretty_name =
989  id2string(struct_tag_type_identifier) + ".clone:()";
990  clone_symbol.base_name="clone";
991  clone_symbol.type=clone_type;
992  clone_symbol.value=clone_body;
993  clone_symbol.mode=ID_java;
994  symbol_table.add(clone_symbol);
995  }
996 }
997 
998 bool java_bytecode_convert_class(
999  const java_class_loadert::parse_tree_with_overlayst &parse_trees,
1000  symbol_tablet &symbol_table,
1001  message_handlert &message_handler,
1002  size_t max_array_length,
1003  method_bytecodet &method_bytecode,
1004  java_string_library_preprocesst &string_preprocess,
1005  const std::unordered_set<std::string> &no_load_classes)
1006 {
1007  java_bytecode_convert_classt java_bytecode_convert_class(
1008  symbol_table,
1009  message_handler,
1010  max_array_length,
1011  method_bytecode,
1012  string_preprocess,
1013  no_load_classes);
1014 
1015  try
1016  {
1017  java_bytecode_convert_class(parse_trees);
1018  return false;
1019  }
1020 
1021  catch(int)
1022  {
1023  }
1024 
1025  catch(const char *e)
1026  {
1027  java_bytecode_convert_class.error() << e << messaget::eom;
1028  }
1029 
1030  catch(const std::string &e)
1031  {
1032  java_bytecode_convert_class.error() << e << messaget::eom;
1033  }
1034 
1035  return true;
1036 }
1037 
1038 static std::string get_final_name_component(const std::string &name)
1039 {
1040  return name.substr(name.rfind("::") + 2);
1041 }
1042 
1043 static std::string get_without_final_name_component(const std::string &name)
1044 {
1045  return name.substr(0, name.rfind("::"));
1046 }
1047 
1060 static void find_and_replace_parameter(
1061  java_generic_parametert &parameter,
1062  const std::vector<java_generic_parametert> &replacement_parameters)
1063 {
1064  // get the name of the parameter, e.g., `T` from `java::Class::T`
1065  const std::string &parameter_full_name =
1066  id2string(parameter.type_variable_ref().get_identifier());
1067  const std::string parameter_name =
1068  get_final_name_component(parameter_full_name);
1069 
1070  // check if there is a replacement parameter with the same name
1071  const auto replacement_parameter_it = std::find_if(
1072  replacement_parameters.begin(),
1073  replacement_parameters.end(),
1074  [&parameter_name](const java_generic_parametert &replacement_param) {
1075  return parameter_name ==
1076  get_final_name_component(
1077  id2string(replacement_param.type_variable().get_identifier()));
1078  });
1079  if(replacement_parameter_it == replacement_parameters.end())
1080  return;
1081 
1082  // A replacement parameter was found, update the identifier
1083  const std::string &replacement_parameter_full_name =
1084  id2string(replacement_parameter_it->type_variable().get_identifier());
1085 
1086  // Check the replacement parameter comes from an outer class
1087  PRECONDITION(has_prefix(
1088  replacement_parameter_full_name,
1089  get_without_final_name_component(parameter_full_name)));
1090 
1091  parameter.type_variable_ref().set_identifier(replacement_parameter_full_name);
1092 }
1093 
1099 static void find_and_replace_parameters(
1100  typet &type,
1101  const std::vector<java_generic_parametert> &replacement_parameters)
1102 {
1103  if(is_java_generic_parameter(type))
1104  {
1105  find_and_replace_parameter(
1106  to_java_generic_parameter(type), replacement_parameters);
1107  }
1108  else if(is_java_generic_type(type))
1109  {
1110  java_generic_typet &generic_type = to_java_generic_type(type);
1111  std::vector<reference_typet> &arguments =
1112  generic_type.generic_type_arguments();
1113  for(auto &argument : arguments)
1114  {
1115  find_and_replace_parameters(argument, replacement_parameters);
1116  }
1117  }
1118  else if(is_java_generic_struct_tag_type(type))
1119  {
1120  java_generic_struct_tag_typet &generic_base =
1121  to_java_generic_struct_tag_type(type);
1122  std::vector<reference_typet> &gen_types = generic_base.generic_types();
1123  for(auto &gen_type : gen_types)
1124  {
1125  find_and_replace_parameters(gen_type, replacement_parameters);
1126  }
1127  }
1128 }
1129 
1133 void convert_annotations(
1134  const java_bytecode_parse_treet::annotationst &parsed_annotations,
1135  std::vector<java_annotationt> &java_annotations)
1136 {
1137  for(const auto &annotation : parsed_annotations)
1138  {
1139  java_annotations.emplace_back(annotation.type);
1140  std::vector<java_annotationt::valuet> &values =
1141  java_annotations.back().get_values();
1142  std::transform(
1143  annotation.element_value_pairs.begin(),
1144  annotation.element_value_pairs.end(),
1145  std::back_inserter(values),
1146  [](const decltype(annotation.element_value_pairs)::value_type &value) {
1147  return java_annotationt::valuet(value.element_name, value.value);
1148  });
1149  }
1150 }
1151 
1156 void convert_java_annotations(
1157  const std::vector<java_annotationt> &java_annotations,
1158  java_bytecode_parse_treet::annotationst &annotations)
1159 {
1160  for(const auto &java_annotation : java_annotations)
1161  {
1162  annotations.emplace_back(java_bytecode_parse_treet::annotationt());
1163  auto &annotation = annotations.back();
1164  annotation.type = java_annotation.get_type();
1165 
1166  std::transform(
1167  java_annotation.get_values().begin(),
1168  java_annotation.get_values().end(),
1169  std::back_inserter(annotation.element_value_pairs),
1170  [](const java_annotationt::valuet &value)
1171  -> java_bytecode_parse_treet::annotationt::element_value_pairt {
1172  return {value.get_name(), value.get_value()};
1173  });
1174  }
1175 }
1176 
1181 void mark_java_implicitly_generic_class_type(
1182  const irep_idt &class_name,
1183  symbol_tablet &symbol_table)
1184 {
1185  const std::string qualified_class_name = "java::" + id2string(class_name);
1186  PRECONDITION(symbol_table.has_symbol(qualified_class_name));
1187  // This will have its type changed
1188  symbolt &class_symbol = symbol_table.get_writeable_ref(qualified_class_name);
1189  const java_class_typet &class_type = to_java_class_type(class_symbol.type);
1190 
1191  // the class must be an inner non-static class, i.e., have a field this$*
1192  // TODO this should be simplified once static inner classes are marked
1193  // during parsing
1194  bool no_this_field = std::none_of(
1195  class_type.components().begin(),
1196  class_type.components().end(),
1197  [](const struct_union_typet::componentt &component)
1198  {
1199  return id2string(component.get_name()).substr(0, 5) == "this$";
1200  });
1201  if(no_this_field)
1202  {
1203  return;
1204  }
1205 
1206  // create a vector of all generic type parameters of all outer classes, in
1207  // the order from the outer-most inwards
1208  std::vector<java_generic_parametert> implicit_generic_type_parameters;
1209  std::string::size_type outer_class_delimiter =
1210  qualified_class_name.rfind('$');
1211  while(outer_class_delimiter != std::string::npos)
1212  {
1213  std::string outer_class_name =
1214  qualified_class_name.substr(0, outer_class_delimiter);
1215  if(symbol_table.has_symbol(outer_class_name))
1216  {
1217  const symbolt &outer_class_symbol =
1218  symbol_table.lookup_ref(outer_class_name);
1219  const java_class_typet &outer_class_type =
1220  to_java_class_type(outer_class_symbol.type);
1221  if(is_java_generic_class_type(outer_class_type))
1222  {
1223  for(const java_generic_parametert &outer_generic_type_parameter :
1224  to_java_generic_class_type(outer_class_type).generic_types())
1225  {
1226  // Create a new generic type parameter with name in the form:
1227  // java::Outer$Inner::Outer::T
1228  irep_idt identifier = qualified_class_name + "::" +
1229  id2string(strip_java_namespace_prefix(
1230  outer_generic_type_parameter.get_name()));
1231  java_generic_parameter_tagt bound = to_java_generic_parameter_tag(
1232  outer_generic_type_parameter.subtype());
1233  bound.type_variable_ref().set_identifier(identifier);
1234  implicit_generic_type_parameters.emplace_back(identifier, bound);
1235  }
1236  }
1237  outer_class_delimiter = outer_class_name.rfind('$');
1238  }
1239  else
1240  {
1241  throw missing_outer_class_symbol_exceptiont(
1242  outer_class_name, qualified_class_name);
1243  }
1244  }
1245 
1246  // if there are any implicit generic type parameters, mark the class
1247  // implicitly generic and update identifiers of type parameters used in fields
1248  if(!implicit_generic_type_parameters.empty())
1249  {
1250  java_implicitly_generic_class_typet new_class_type(
1251  class_type, implicit_generic_type_parameters);
1252 
1253  // Prepend existing parameters so choose those above any inherited
1254  if(is_java_generic_class_type(class_type))
1255  {
1256  const java_generic_class_typet::generic_typest &class_type_params =
1257  to_java_generic_class_type(class_type).generic_types();
1258  implicit_generic_type_parameters.insert(
1259  implicit_generic_type_parameters.begin(),
1260  class_type_params.begin(),
1261  class_type_params.end());
1262  }
1263 
1264  for(auto &field : new_class_type.components())
1265  {
1266  find_and_replace_parameters(
1267  field.type(), implicit_generic_type_parameters);
1268  }
1269 
1270  for(auto &base : new_class_type.bases())
1271  {
1272  find_and_replace_parameters(
1273  base.type(), implicit_generic_type_parameters);
1274  }
1275 
1276  class_symbol.type = new_class_type;
1277  }
1278 }
messaget
Class that provides messages with a built-in verbosity 'level'.
Definition: message.h:152
java_bytecode_parse_treet::classt::implements
implementst implements
Definition: java_bytecode_parse_tree.h:270
java_bytecode_parse_treet::loading_successful
bool loading_successful
Definition: java_bytecode_parse_tree.h:313
method_bytecodet
Definition: ci_lazy_methods.h:34
symbol_table_baset::has_symbol
bool has_symbol(const irep_idt &name) const
Check whether a symbol exists in the symbol table.
Definition: symbol_table_base.h:87
dstringt
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:37
symbol_tablet
The symbol table.
Definition: symbol_table.h:20
java_class_typet::componentt
Definition: java_types.h:202
java_root_class.h
java_bytecode_parse_treet::classt::is_annotation
bool is_annotation
Definition: java_bytecode_parse_tree.h:219
java_bytecode_language.h
arith_tools.h
java_class_typet::set_synthetic
void set_synthetic(bool synthetic)
marks class synthetic
Definition: java_types.h:424
java_class_typet::set_is_static_class
void set_is_static_class(const bool &is_static_class)
Definition: java_types.h:358
java_class_typet::set_is_anonymous_class
void set_is_anonymous_class(const bool &is_anonymous_class)
Definition: java_types.h:368
java_bytecode_parse_treet
Definition: java_bytecode_parse_tree.h:23
typet
The type of an expression, extends irept.
Definition: type.h:29
java_bytecode_parse_treet::methodt
Definition: java_bytecode_parse_tree.h:85
unsupported_java_class_signature_exceptiont
An exception that is raised for unsupported class signature.
Definition: java_types.h:1075
struct_typet::add_base
void add_base(const struct_tag_typet &base)
Add a base class/struct.
Definition: std_types.cpp:88
java_bytecode_convert_classt::convert
void convert(const classt &c, const overlay_classest &overlay_classes)
Convert a class, adding symbols to the symbol table for its members.
Definition: java_bytecode_convert_class.cpp:270
java_bytecode_parse_treet::classt::is_synthetic
bool is_synthetic
Definition: java_bytecode_parse_tree.h:218
prefix.h
replace
void replace(const union_find_replacet &replace_map, string_not_contains_constraintt &constraint)
Definition: string_constraint.cpp:67
java_bytecode_convert_classt::is_ignored_method
static bool is_ignored_method(const irep_idt &class_name, const methodt &method)
Check if a method is an ignored method, by one of two mechanisms:
Definition: java_bytecode_convert_class.cpp:161
generate_class_stub
void generate_class_stub(const irep_idt &class_name, symbol_table_baset &symbol_table, message_handlert &message_handler, const struct_union_typet::componentst &componentst)
Definition: java_utils.cpp:89
struct_union_typet::componentst
std::vector< componentt > componentst
Definition: std_types.h:135
java_bytecode_convert_classt::java_bytecode_convert_classt
java_bytecode_convert_classt(symbol_tablet &_symbol_table, message_handlert &_message_handler, size_t _max_array_length, method_bytecodet &method_bytecode, java_string_library_preprocesst &_string_preprocess, const std::unordered_set< std::string > &no_load_classes)
Definition: java_bytecode_convert_class.cpp:37
struct_tag_typet
A struct tag type, i.e., struct_typet with an identifier.
Definition: std_types.h:490
java_class_typet::set_is_annotation
void set_is_annotation(bool is_annotation)
marks class an annotation
Definition: java_types.h:436
java_bytecode_parse_treet::classt::is_final
bool is_final
Definition: java_bytecode_parse_tree.h:216
java_bytecode_parse_treet::classt::is_inner_class
bool is_inner_class
Definition: java_bytecode_parse_tree.h:220
java_bytecode_convert_classt::methodt
java_bytecode_parse_treet::methodt methodt
Definition: java_bytecode_convert_class.cpp:107
to_string
std::string to_string(const string_not_contains_constraintt &expr)
Used for debug printing.
Definition: string_constraint.cpp:55
messaget::eom
static eomt eom
Definition: message.h:283
namespace.h
java_bytecode_convert_classt::no_load_classes
std::unordered_set< std::string > no_load_classes
Definition: java_bytecode_convert_class.cpp:176
java_bytecode_parse_treet::membert::has_annotation
bool has_annotation(const irep_idt &annotation_id) const
Definition: java_bytecode_parse_tree.h:78
java_class_typet::set_inner_name
void set_inner_name(const irep_idt &name)
Set the name of a java inner class.
Definition: java_types.h:521
java_class_typet
Definition: java_types.h:199
java_bytecode_convert_classt::annotationt
java_bytecode_parse_treet::annotationt annotationt
Definition: java_bytecode_convert_class.cpp:108
java_generic_class_typet::generic_types
const generic_typest & generic_types() const
Definition: java_types.h:925
java_bytecode_parse_treet::classt::is_public
bool is_public
Definition: java_bytecode_parse_tree.h:215
java_bytecode_convert_classt::fieldt
java_bytecode_parse_treet::fieldt fieldt
Definition: java_bytecode_convert_class.cpp:106
java_string_library_preprocesst::add_string_type
void add_string_type(const irep_idt &class_name, symbol_tablet &symbol_table)
Add to the symbol table type declaration for a String-like Java class.
Definition: java_string_library_preprocess.cpp:209
java_bytecode_convert_classt::overlay_classest
std::list< std::reference_wrapper< const classt > > overlay_classest
Definition: java_bytecode_convert_class.cpp:117
find_closing_delimiter
size_t find_closing_delimiter(const std::string &src, size_t open_pos, char open_char, char close_char)
Finds the corresponding closing delimiter to the given opening delimiter.
Definition: java_utils.cpp:233
java_class_typet::set_is_enumeration
void set_is_enumeration(const bool is_enumeration)
marks class as an enumeration
Definition: java_types.h:400
java_bytecode_parse_treet::classt::enum_elements
size_t enum_elements
Definition: java_bytecode_parse_tree.h:225
expr_initializer.h
java_bytecode_convert_classt::classt
java_bytecode_parse_treet::classt classt
Definition: java_bytecode_convert_class.cpp:105
java_class_loadert::parse_tree_with_overlayst
std::list< java_bytecode_parse_treet > parse_tree_with_overlayst
A list of parse trees supporting overlay classes.
Definition: java_class_loader.h:30
java_bytecode_convert_classt::string_preprocess
java_string_library_preprocesst & string_preprocess
Definition: java_bytecode_convert_class.cpp:114
id2string
const std::string & id2string(const irep_idt &d)
Definition: irep.h:44
java_bytecode_parse_treet::classt::is_enum
bool is_enum
Definition: java_bytecode_parse_tree.h:214
java_bytecode_parse_treet::annotationt
Definition: java_bytecode_parse_tree.h:33
struct_union_typet::set_tag
void set_tag(const irep_idt &tag)
Definition: std_types.h:164
find_closing_semi_colon_for_reference_type
size_t find_closing_semi_colon_for_reference_type(const std::string src, size_t starting_point)
Finds the closing semi-colon ending a ClassTypeSignature that starts at starting_point.
Definition: java_types.cpp:515
java_bytecode_parse_treet::classt::name
irep_idt name
Definition: java_bytecode_parse_tree.h:212
PRECONDITION
#define PRECONDITION(CONDITION)
Definition: invariant.h:464
add_java_array_types
void add_java_array_types(symbol_tablet &symbol_table)
Register in the symbol_table new symbols for the objects java::array[X] where X is byte,...
Definition: java_bytecode_convert_class.cpp:790
extract_generic_interface_reference
static optionalt< std::string > extract_generic_interface_reference(const optionalt< std::string > &signature, const std::string &interface_name)
Auxiliary function to extract the generic interface reference of an interface with the specified name...
Definition: java_bytecode_convert_class.cpp:229
struct_typet::bases
const basest & bases() const
Get the collection of base classes/structs.
Definition: std_types.h:257
message_handlert
Definition: message.h:27
java_bytecode_convert_method.h
dstringt::empty
bool empty() const
Definition: dstring.h:88
java_bytecode_parse_treet::classt::is_private
bool is_private
Definition: java_bytecode_parse_tree.h:215
cprover_methods_to_ignore
const std::unordered_set< std::string > cprover_methods_to_ignore
Methods belonging to the class org.cprover.CProver that should be ignored (not converted),...
Definition: java_utils.cpp:461
extract_generic_superclass_reference
static optionalt< std::string > extract_generic_superclass_reference(const optionalt< std::string > &signature)
Auxiliary function to extract the generic superclass reference from the class signature.
Definition: java_bytecode_convert_class.cpp:190
java_bytecode_convert_classt::is_overlay_method
static bool is_overlay_method(const methodt &method)
Check if a method is an overlay method by searching for ID_overlay_method in its list of annotations.
Definition: java_bytecode_convert_class.cpp:136
optionalt
nonstd::optional< T > optionalt
Definition: optional.h:35
java_class_typet::set_final
void set_final(bool is_final)
Definition: java_types.h:378
java_class_typet::set_interface
void set_interface(bool interface)
marks class an interface
Definition: java_types.h:448
java_class_typet::set_outer_class
void set_outer_class(const irep_idt &outer_class)
Definition: java_types.h:338
java_bytecode_parse_treet::classt::is_protected
bool is_protected
Definition: java_bytecode_parse_tree.h:215
java_class_typet::set_super_class
void set_super_class(const irep_idt &super_class)
Definition: java_types.h:348
java_bytecode_convert_classt::symbol_table
symbol_tablet & symbol_table
Definition: java_bytecode_convert_class.cpp:111
java_class_typet::components
const componentst & components() const
Definition: java_types.h:226
java_bytecode_parse_treet::parsed_class
classt parsed_class
Definition: java_bytecode_parse_tree.h:305
messaget::get_message_handler
message_handlert & get_message_handler()
Definition: message.h:181
java_bytecode_convert_classt::method_bytecode
method_bytecodet & method_bytecode
Definition: java_bytecode_convert_class.cpp:113
java_bytecode_parse_treet::membert::name
irep_idt name
Definition: java_bytecode_parse_tree.h:68
java_class_typet::set_access
void set_access(const irep_idt &access)
Definition: java_types.h:318
to_java_generic_parameter
const java_generic_parametert & to_java_generic_parameter(const typet &type)
Definition: java_types.h:771
suffix.h
symbolt
Symbol table entry.
Definition: symbol.h:28
irept::set
void set(const irep_namet &name, const irep_idt &value)
Definition: irep.h:442
java_bytecode_parse_treet::classt::is_static_class
bool is_static_class
Definition: java_bytecode_parse_tree.h:221
java_string_library_preprocesst
Definition: java_string_library_preprocess.h:36
java_bytecode_convert_classt::check_field_exists
bool check_field_exists(const fieldt &field, const irep_idt &qualified_fieldname, const struct_union_typet::componentst &fields) const
Definition: java_bytecode_convert_class.cpp:619
java_string_library_preprocesst::is_known_string_type
bool is_known_string_type(irep_idt class_name)
Check whether a class name is known as a string type.
Definition: java_string_library_preprocess.cpp:1455
java_class_typet::set_is_inner_class
void set_is_inner_class(const bool &is_inner_class)
Definition: java_types.h:328
java_bytecode_parse_treet::classt::signature
optionalt< std::string > signature
Definition: java_bytecode_parse_tree.h:271
java_bytecode_parse_treet::fieldt
Definition: java_bytecode_parse_tree.h:186
java_generic_struct_tag_typet
Class to hold type with generic type arguments, for example java.util.List in either a reference of t...
Definition: java_types.h:802
class_identifier.h
java_bytecode_parse_treet::classt
Definition: java_bytecode_parse_tree.h:197
java_class_typet::set_abstract
void set_abstract(bool abstract)
marks class abstract
Definition: java_types.h:412
java_generic_class_typet
Class to hold a class with generics, extends the java class type with a vector of java generic type p...
Definition: java_types.h:916
messaget::debug
mstreamt & debug() const
Definition: message.h:415
java_types.h
java_utils.h
messaget::warning
mstreamt & warning() const
Definition: message.h:390
java_bytecode_parse_treet::classt::is_interface
bool is_interface
Definition: java_bytecode_parse_tree.h:217
java_generic_type_from_string
std::vector< typet > java_generic_type_from_string(const std::string &class_name, const std::string &src)
Converts the content of a generic class type into a vector of Java types, that is each type variable ...
Definition: java_types.cpp:747
java_bytecode_convert_classt
Definition: java_bytecode_convert_class.cpp:35
std_expr.h
java_bytecode_parse_treet::classt::is_abstract
bool is_abstract
Definition: java_bytecode_parse_tree.h:213
java_bytecode_parse_treet::classt::inner_name
irep_idt inner_name
Definition: java_bytecode_parse_tree.h:212
java_bytecode_parse_treet::classt::outer_class
irep_idt outer_class
Definition: java_bytecode_parse_tree.h:224
c_types.h
java_bytecode_convert_classt::operator()
void operator()(const java_class_loadert::parse_tree_with_overlayst &parse_trees)
Converts all the class parse trees into a class symbol and adds it to the symbol table.
Definition: java_bytecode_convert_class.cpp:68
java_bytecode_parse_treet::classt::is_anonymous_class
bool is_anonymous_class
Definition: java_bytecode_parse_tree.h:222
java_bytecode_parse_treet::classt::super_class
irep_idt super_class
Definition: java_bytecode_parse_tree.h:212
java_bytecode_convert_classt::max_array_length
const size_t max_array_length
Definition: java_bytecode_convert_class.cpp:112
java_bytecode_convert_class.h