Rust translation: ~100 signatures that contradict the Java (triage list)

Aperta
#202 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
java, rust
Ambito
tooling

Direzione di ricerca

Start with the listed rejected Rust signatures and compare each case with the corresponding Java method, using #167 as the issue's reference point. Triage the cases by checking whether the reported signature matches Java's ownership, borrowing, mutation, and null behavior. The work is done when each case has a justified verdict or printer-mode explanation; the payload gives no specific test or entry point to run.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug front-end:rust

Of the fernflower functions rustc rejects, about 100 have a signature that contradicts the Java: no correct body exists against it, whatever the body printer does. Each is either a wrong verdict (maddi-mod) or a printer mode choice that ignores the verdict, so the list is an oracle in the spirit of #167, and needs triage per case.

The patterns, with examples:

  1. A borrow returned for an object the method creates or removes (the result's independence). The method should return an owned value or a Shared handle. Examples:
    • Exprent.toJava variants return &TextBuffer for a new buffer;
    • IfHelper.buildGraph, ConcatenationHelper.createConcatExprent and SimplifyExprentsHelper.isPPIorMMI return a borrow of a node they build;
    • FastFixedSet.getCopy returns &Self;
    • ListStack.pop and VBStyleCollection.remove/putWithKey return &E for an element they remove.
  2. &self on a method whose overrides modify the object: Instruction.initInstruction, Exprent.inferExprType, Exprent.replaceExprent, PooledConstant.resolveConstant, IStructGeneralAttribute.initContent, and the JADNameProvider.renameParameter trait method. The analysis already warns about this as [override-weakens-computed]. The family method (the dispatcher) should take the union of its overrides' modes.
  3. A borrowed parameter the method stores: DecompilerContext.startClass/startMethod, Instruction.create (operands), Fernflower(provider, saver, ...), TypeAnnotationWriteHelper(annotation), StructClass/StructField/StructMethod (attributes). The parameter is kept (dependent), so it must be owned or shared, not &.
  4. An owned parameter the method modifies for the caller: IMatchable.match(MatchEngine) and Exprent.match*, where Java changes the engine through checkAndSetVariableValue. This needs &mut.
  5. A getter that returns an owned copy of shared, mutable state: DecompilerContext.getImportCollector/getBytecodeSourceMapper/getLimitContainer/getVarProcessor/getProperty. Changes made through the copy are lost.
  6. A non-null result where Java returns null: the FastFixedSet and FastSparseSet iterators' next() return &E, but Java returns null past the end.

The full list (function | left | reason), one line per case:

100 cases
ConcatenationHelper::create_concat_exprent | left | wrong signature: returns Option<&'r Shared> borrowed from the list, but Java returns a new FunctionExprent
ExprProcessor::write_type_annotation_before_type | left | wrong signature: &Vec but Java pops the helpers' paths; returns owned Vec of non-Clone helpers that Java shares
ExprProcessor::write_nested_class | left | wrong signature: returns &'r Vec borrowed from the param, Java returns a new filtered list
ExprProcessor::non_array_path | left | wrong signature: &Vec but Java polls the helpers' paths; owned non-Clone result
FinallyProcessor::get_finally_information | left | struct/type problem: Record.map_last is &'a HashMap, cannot be built from a local map; also ExprProcessor::new needs &'a mut from &mut self (wrong signature)
IfHelper::build_graph | left | wrong signature: returns &'r IfNode but Java returns a newly built node
MergeHelper::try_convert_for_each | left | wrong signature: init_exprents &mut [Shared<Exprent>] cannot hold Java's null entries
PatternHelper::replace_assignments_with_pattern_variables_2 | left | struct/type problem: Box<dyn FnMut()> is 'static so it cannot capture Shared<Exprent<'s>>; get_cleaner returns &dyn FnMut, which cannot be called
PatternHelper::find_next_pattern_var_candidate | left | wrong signature (callee): find_record_pattern_candidate returns Candidate<'r> tied to the tracker borrow, and the tracker here is a local copy (E0515, checked)
PatternHelper::find_init_record_pattern_candidate | left | wrong signature (callee): find_record_pattern_candidate result borrows the local VarTracker
PatternHelperVarTracker::copy | left | wrong signature: `&mut self -> Option<&Shared<..>>` but Java returns a new tracker and leaves this one unchanged (needs `&self -> Option<Shared<..>>`)
SimplifyExprentsHelper::is_pp_ior_mmi | left | wrong signature: returns `Option<&'r Shared>` borrowed from `first`, but Java returns a new FunctionExprent
SimplifyExprentsHelper::is_simple_constructor_invocation | left | wrong signature: returns a borrow (&'r Shared) of the NewExprent that the body detaches (setInstance(null)); must return owned
SimplifyExprentsHelper::build_iff | left | struct/type problem: new_exit_exprent takes MethodDescriptor by value (holds &'a mut [..], not Clone); Java shares ifExit's descriptor
SwitchHelperStringSwitchRecognizer::find_real_case_value | left | wrong signature: if_statement and selector_qualifier have independent Exprent lifetimes, cannot be compared with equals
SwitchHelperStringSwitchRecognizer::recognize | left | wrong signature: returned candidate lifetime is &self's, callees return the selector borrow's
SwitchHelperSwitchOnStringCandidate::used_switch | left | wrong signature: returns &HashSet but Java builds a new Set.of each call (callees return owned)
SwitchPatternHelperJavacReferenceFinder::find_candidate | left | wrong signature: returns Option<&Candidate> of a new object; the Candidate also needs &'a mut borrows of self's fields, and Root.first_exprents is an owned Vec so th
SwitchPatternHelperJavacReferenceFinder::get_root | left | wrong signature: &self -> Option<&Root> of a newly built Root
SwitchPatternHelperJavacReferenceFinder::collect_patterns | left | wrong signature: returns Option<&HashMap> of a new local map
SwitchPatternHelperJavacReferenceFinder::collect_guards | left | wrong signature: returns &Shared<PatternContainer> of a new container
SwitchPatternHelperJavacReferenceFinder::normalize_candidate_with_broken_edges | left | wrong signature/struct: old_candidate is &mut but Java returns it (owned return); PatternVariableCandidate holds &'a mut Vec + Box<dyn FnMut>,
SwitchPatternHelperJavacReferenceFinder::try_to_find_nested_switch | left | wrong signature/struct: previous_candidate &mut but stored in the returned list; same candidate fields problem
SwitchPatternHelperJavacReferenceRecognizer::recognize | left | callee/struct: find_candidate returns a borrow; no impl SwitchHelperSwitchOnCandidate for SwitchOnReferenceCandidate; Box<dyn> is 'static vs Statement<'_>
FastFixedSetFactoryFastFixedSet::get_copy | left | wrong signature: returns &Self for a new copy (must be owned)
FastFixedSetFactoryFastFixedSet::iterator | left | struct/type problem: Box<dyn Iterator> needs E: 'static, iterator struct has no Iterator impl, ctor takes the set by value from &mut self
FastFixedSetFactoryFastFixedSetIterator::next | left | wrong signature: Java returns null past the end, &E cannot
FastSparseSetFactoryFastSparseSetIterator::next | left | wrong signature: Java returns null past the end, &E cannot
JADNameProvider/IVariableNameProvider::rename_parameter | left | wrong signature: trait &self, Java computeIfAbsent + getNewName mutate (inherent is &mut)
ListStack::pop | left | wrong signature: returns &T of a removed element (needs T)
ListStack::pop_2 | left | wrong signature: Option<&T> of removed elements (needs Option<T>)
VBStyleCollection::put_with_key | left | wrong signature: returns Option<&E> of the replaced (removed) element; needs Option<E>
VBStyleCollection::remove_2 | left | wrong signature: returns &E of removed element; also needs null-key test
ExprUtil::get_synthetic_parameters_mask_2 | left | wrong signature: returns a borrowed &'r Vec, but Java returns a fresh list in one branch (and the wrapper's list sits behind a temporary Shared); its elements are nullable too
Exprent::find_object | left | wrong signature: returns an owned Box<dyn IMatchable>, but Java returns a shared child (and Shared<Exprent> is not IMatchable)
Exprent::match_const_exprent | left | wrong signature: takes MatchEngine by value, but Java mutates the caller's engine (checkAndSetVariableValue); match_exprent needs &mut
Exprent::to_java_2_exit_exprent | left | wrong signature: returns &TextBuffer, but Java returns a new buffer
Exprent::to_java_2_function_exprent | left | wrong signature: returns &TextBuffer, but Java returns a new buffer (nothing in self to borrow)
Exprent::to_java_2_if_exprent | left | wrong signature: returns &TextBuffer for a new buffer
Exprent::match_invocation_exprent | left | struct/type: engine variables are Box<dyn Any> ('static), Shared<Exprent<'a>> cannot be stored; also engine taken by value though Java mutates it
Exprent::to_java_2_monitor_exprent | left | wrong signature: returns &TextBuffer for a new buffer
Exprent::infer_expr_type | left | wrong signature: &self, but function/field/invocation/new/var variants take &mut self (Java sets needsCast/inferredType)
Exprent::replace_exprent | left | wrong signature: &self and borrowed new_expr, but variants take &mut self and owned new_expr (Java mutates this)
Exprent::match | left | wrong signature in callees: match_const/match_invocation take MatchEngine by value, dispatcher has &mut
Display for Exprent::fmt | left | wrong signature: to_string/toJava take &mut self, fmt has &self
ClassReference14Processor::process_class_references | left | struct/type problem: Map/Set keyed by ClassWrapper by value (no Hash/Eq, owned by the node); wrong signature: &ClassNode but the Java adds to the wrapper's hidden member
ClassReference14Processor::process_class_rec | left | same: HashSet<ClassWrapper> by value; &ClassNode cannot yield the &mut ClassWrapper replace_invocations needs; initializers replaced through a & wrapper
ClassWriter::field_to_java | left | wrong signature: independent elided lifetimes on wrapper/fd/tracer; initializer Exprent<'w>.to_java_2 needs a tracer of the same lifetime (Shared is invariant)
ClassWriter::add_tracer | left | wrong signature (callee): DecompilerContext::get_bytecode_source_mapper returns an owned copy, so add_tracer would register on a temporary; mapper's add_tracer also takes the tracer by value
ClassWriter::get_field_type_data | left | wrong signature: returns Rc<GenericFieldDescriptor>, but fd.getSignature() is nullable (Java returns an entry with a null value)
ClassesProcessor::load_classes | left | struct/type problem: ClassNode owns nested by value with a Box parent; Java shares a node between mapRootClasses, the super node's nested list and the parent back link
ClassesProcessor::write_class | left | wrong signature: NestedClassProcessor::process_class(&root, &mut node) called with root twice; DecompilerContext::start_class must store a borrowed ImportCollector
DecompilerContext::get_current_context | left | missing runtime: static ThreadLocal currentContext not translated; returns context by value
DecompilerContext::set_property | left | wrong signature: value borrowed (Box<dyn Any> cannot be cloned), context returned by value so the put is lost
DecompilerContext::start_class | left | wrong signature: borrowed ImportCollector must be stored in the context
DecompilerContext::start_method | left | wrong signature: borrowed VarProcessor must be stored in the context
DecompilerContext::get_property | left | wrong signature: owned Box<dyn Any> return of a map value Java shares (cannot clone dyn Any)
DecompilerContext::get_limit_container | left | wrong signature: owned return of a shared container with a mutable counter
DecompilerContext::get_struct_context | left | wrong signature: owned StructContext return, field is &'a mut
DecompilerContext::get_cancellation_manager | left | wrong signature: Box return, field is &'a mut dyn
DecompilerContext::get_import_collector | left | wrong signature: owned return of a collector callers mutate
DecompilerContext::get_var_processor | left | wrong signature: owned return of a VarProcessor callers mutate
DecompilerContext::get_bytecode_source_mapper | left | wrong signature: owned return of a mapper callers mutate
Fernflower::new_2 | left | wrong signature: saver borrowed (&dyn) but new() needs owned Box to store
Statement::get_exprents_or_sequential_objects | left | struct/type problem: returns &Vec<Box<dyn IMatchable>>, exprents are Vec<Shared<Exprent>>, sequential objects a temporary
Statement::get_top_parent | left | wrong signature: returns &Shared but Java returns `this` when there is no parent (needs owned Shared)
Statement::new_if_statement_2 | left | wrong signature: the constructor hands out `this` (edge source, post = this); it returns Self, so Shared::of(&this) is invalid
Statement::new_root_statement | left | wrong signature: the constructor calls first.setParent(this) before `this` is in a Shared
Statement::init_exprents_switch_statement | left | wrong signature: set_case_values takes Vec by value, but Java shares caseValues (SwitchHelper later does clear/addAll in place)
Statement::sort_edges_and_nodes | left | wrong callee signatures: collect_regular_edges_indices and replace_null_statements_with_basic_blocks take the list by value (Java fills it in place); the case list must also hold null
Statement::replace_null_statements_with_basic_blocks | left | wrong signature: `statements` is owned, so statements.set is lost; its non-null elements make the null test impossible
Statement::init_exprents | left | wrong signature: &self, but the If/Switch/Synchronized initExprents modify this (they take &mut self)
Statement::replace_exprent | left | wrong signature: &self, but the Do/If/Switch/Synchronized replaceExprent modify this (they take &mut self)
VarDefinitionHelper::find_lvt_entry_2 | left | wrong signature: returns &'r borrowed from children that only exist in the fresh get_all_exprents list
VarDefinitionHelper::propogate_lv_ts | left | wrong signature (callee): get_variable_namer returns &dyn IVariableNameProvider but rename needs &mut; find_types/apply_types left too
VarProcessor::set_var_versions | left | wrong signature (callee): VarVersionsProcessor::new takes MethodDescriptor by value, only &'a is held (not Clone)
VarProcessor::set_var_definitions | left | wrong signature: VarDefinitionHelper::new needs &'a mut VarProcessor<'a>, only &mut self here
VarProcessor::get_var_names | left | wrong signature: &Vec<String> cannot be the map's values() view
VarVersionNode/IGraphNode::get_predecessor_nodes | left | wrong signature: returns &Vec of a list Java builds fresh; same Box<dyn IGraphNode> problem
VarVersionsProcessor::new | left | wrong signature: md by value, but VarTypeProcessor::new stores &'a MethodDescriptor
MethodProcessorRunnable::code_to_java | left | wrong signature: md/var_proc are lent for an anonymous lifetime, but FinallyProcessor::new stores them as `&'a mut ...<'a>`, and ExprProcessor/PPandMMHelper need them again afterwards
NestedClassProcessor::check_not_found_classes | left | wrong signature/struct: moves children into root's subtree (root is &); ClassNode is not Clone and parent is an owned Box
NestedClassProcessor::insert_nested_class | left | wrong signature/struct: pushes child into a node of root's tree (root is &), and child is &mut, not owned
NestedMemberAccess::replace_access_exprent | left | wrong signature: returns `Option<&'r Shared<Exprent>>` but Java returns a freshly built exprent; it also adds to another node's wrapper hidden members (& only)
NestedMemberAccess::replace_function | left | wrong signature: returns `&'r` borrowed, but the result is a new copy
SSAConstructorSparseEx::split_variables | left | wrong signature: root and mt get independent lifetimes, but DirectGraph<'a> from root and DotExporter::to_dot_file<'s> need the same (invariant) lifetime
SSAConstructorSparseEx::ssa_statements | left | wrong signature: dgraph/mt have independent lifetimes for DotExporter::to_dot_file_2; also needs varmaparr[1] == null (see process_exprent)
SSAUConstructorSparseEx::split_variables | left | wrong signature: same independent root/mt lifetimes against DotExporter::to_dot_file
SSAUConstructorSparseEx::ssa_statements | left | wrong signature: dgraph/mt lifetimes for DotExporter::to_dot_file; also needs varmaparr[1] == null
FastExtendedPostdominanceHelper::calc_reachability_supp_points | left | wrong signature: iterate_reachability is &self yet its action writes mapSupportPoints, which iterate_reachability reads in the same pass
FastExtendedPostdominanceHelper::iterate_reachability | left | struct/type: action takes mapSets by value with non-null values; Java shares the map and stores null entries (containsKey true, get null); FastFixedSet not Clone
StructGeneralAttribute::init_content | left | wrong signature: &self and &DataInputFullStream, but the per-kind initContent mutates self and reads (mutates) data
BasicBlock/IGraphNode::get_predecessor_nodes | left | wrong signature: returns &Vec of a list Java builds fresh; also Box<dyn IGraphNode> ('static) cannot hold Shared<BasicBlock<'a>>
GenericMain::get_generic_type_annotations | left | struct/type: TypeAnnotationWriteHelper is owned, non-Clone, but Java shares helpers between lists (and mutates them via &Vec: wrong signature)
GenericType/Display::fmt | left | wrong signature: to_string/append_type_arguments take &mut self, fmt has &self (Java toString modifies nothing)
TypeAnnotationWriteHelper::new | left | wrong signature: borrowed &TypeAnnotation must be stored (field owns TypeAnnotation); Java shares it
ExceptionDeobfuscator::duplicate_merged_matched_exception_catch_blocks | left | struct/type problem: builds new ExceptionRangeCFGs (&'a mut Vec field); get_exception_range returns & but Java calls setHandler on it
IrreducibleCFGDeobfuscator::copy_statement | left | wrong signature: returns &'r Shared, but when `to` is null Java returns a freshly made copy
PooledConstant::resolve_constant | left | wrong signature: &self, but the LinkConstant and PrimitiveConstant overrides change the object (their variants take &mut self)
Instruction::init_instruction | left | signature wrong: &self, but the Jump/Switch overrides modify the object (their &mut self init_* methods)

🤖 Generated with Claude Code

Lingua principale
Java
Stelle
1
Fork
1
Merge medio
48m
PR unite (30g)
2

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di CodeLaser/maddi

Tutte le issue di CodeLaser/maddi

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.