mirror of
				https://github.com/Z3Prover/z3
				synced 2025-11-04 13:29:11 +00:00 
			
		
		
		
	Fix inconsistent emission of Java enumeration files. The ordering of emitted
enum values is not consistent between python 2 or 3. The root cause of the problem was a dictionary's keys being iterated over which has no defined order. This has been fixed by iterating over the dictionary's items and ordering by values. We could order by key rather than the values but seeing as these represent an enum, ordering by value makes more sense.
This commit is contained in:
		
							parent
							
								
									b3713e7496
								
							
						
					
					
						commit
						3042f0f964
					
				
					 1 changed files with 3 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -330,13 +330,13 @@ def mk_z3consts_java_internal(api_files, package_name, output_dir):
 | 
			
		|||
                        efile.write('public enum %s {\n' % name)
 | 
			
		||||
                        efile.write
 | 
			
		||||
                        first = True
 | 
			
		||||
                        for k in decls:
 | 
			
		||||
                            i = decls[k]
 | 
			
		||||
                        # Iterate over key-value pairs ordered by value
 | 
			
		||||
                        for k, v in sorted(decls.items(), key=lambda pair: pair[1]):
 | 
			
		||||
                            if first:
 | 
			
		||||
                                first = False
 | 
			
		||||
                            else:
 | 
			
		||||
                                efile.write(',\n')
 | 
			
		||||
                            efile.write('    %s (%s)' % (k, i))
 | 
			
		||||
                            efile.write('    %s (%s)' % (k, v))
 | 
			
		||||
                        efile.write(";\n")
 | 
			
		||||
                        efile.write('\n    private final int intValue;\n\n')
 | 
			
		||||
                        efile.write('    %s(int v) {\n' % name)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue